2014-06-25 24 views
-1

我会写一些代码来询问用户在xcode 5上为ios7.1启用推送通知,这里是我的代码。单击确定或不允许后,xcode推送通知

- (IBAction)funcTabToAllow:(id)sender 
{ 
    [self PushAllow]; 
} 

- (BOOL)PushAllow 
{ 
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes: 
    (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)]; 

    return YES; 
} 

和任何工作正常,现在当用户点击我的按钮,一个警告框显示用于向用户询问是否OK不要让,这里是形象。

enter image description here

现在怎么知道,如果用户触摸OK不允许?我想如果用户点击确定我会写一些日志。

感谢您的帮助。

+0

你看过'registerForRemoteNotificationTypes:'的文档吗? –

+0

@JesseRusak我会坚果我不知道如何自定义'UIRemoteNotificationTypeAlert' – vietnguyen09

回答

1

如果用户允许您的应用程序接收推送通知,在这里你会得到一个回调在你的AppDelegate:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken 

实施该方法以接收回调。

失败时,将其称为:

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error 

the documentation for registerForRemoteNotificationTypes:得到这些从文本。文档是你的朋友。