在iOS上推送通知

时间:2013-02-11 09:49:32

标签: ios iphone apple-push-notifications

我按照本教程在我的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);
}

我想要的就是能够禁用推送通知。该教程指出我应该使用上面的代码选择此选项,但我什么也看不见。

1 个答案:

答案 0 :(得分:2)

你在正确的地方检查吗?正确的地方是设置 - >通知。该应用程序不会直接出现在“设置”列表中,除非您实际配置了设置(即使这样设置,通知设置也不会出现在那里)。