我按照本教程在我的 iOS 应用程序中实现推送,Apple Push Notification Services Tutorial
我按照说明做了所有事情,推送通知效果很好。但是,我在设置菜单中看不到我的应用程序,因此如果我愿意,我可以禁用推送通知。
我添加到我的代码中的是:
在 delegate.m 文件中:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
// Let the device know we want to receive push notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
return YES;
}
和
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSLog(@"My token is: %@", deviceToken);
}
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
NSLog(@"Failed to get token, error: %@", error);
}
我想要的只是能够禁用推送通知。本教程指出我应该使用上面的代码拥有这个选项,但我什么也没看到。