didRegisterForRemoteNotificationsWithDeviceToken: 不调用 registerForRemoteNotificationTypes:? [英] didRegisterForRemoteNotificationsWithDeviceToken: doesn't invoke on calling registerForRemoteNotificationTypes:?

查看:34
本文介绍了didRegisterForRemoteNotificationsWithDeviceToken: 不调用 registerForRemoteNotificationTypes:?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用基于导航的应用程序中的推送通知.在 AppDelegate.m didRegisterForRemoteNotificationsWithDeviceToken: 调用 registerForRemoteNotificationTypes 时不调用:代码如下所示:

I am working with push notifications in a navBased app. in AppDelegate.m didRegisterForRemoteNotificationsWithDeviceToken: doesn't invoke on calling registerForRemoteNotificationTypes: code looks like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

    [self.window addSubview:navigationController.view];
    [self.window makeKeyAndVisible];

    return YES;
}



- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    // Get a hex string from the device token with no spaces or < >
    NSLog(@"applicationDidFinishLaunchingWithOptions dev token test");

    NSString *deviceTokenStr = [[[[deviceToken description]
                          stringByReplacingOccurrencesOfString: @"<" withString: @""] 
                         stringByReplacingOccurrencesOfString: @">" withString: @""] 
                        stringByReplacingOccurrencesOfString: @" " withString: @""];

    NSLog(@"Device Token: %@", deviceTokenStr);
}

我很确定配置文件不是问题所在.我发现错误:

I am quite sure that provisioning profile is not the problem. and i found error:

注册错误.错误:错误域=NSCocoaErrorDomain Code=3000没有为应用程序找到有效的aps-environment"授权字符串" UserInfo=0x115490 {NSLocalizedDescription=没有为应用程序找到有效的aps-environment"授权字符串}

Error in registration. Error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x115490 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}

谁能告诉我这段代码发生了什么并且它不起作用?谢谢

can anyone tell me whats going on in this code and y its not working? thanx

推荐答案

检查这个:链接并确保您已打开 5223 端口.

Check this: link And make sure that you have 5223 port opened.

这篇关于didRegisterForRemoteNotificationsWithDeviceToken: 不调用 registerForRemoteNotificationTypes:?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆