iPhone registerForRemoteNotificationTypes不会产生一个错误,但不火的委托,让设备令牌 [英] iPhone registerForRemoteNotificationTypes does not generate an error but does not fire delegate that gives device token

查看:114
本文介绍了iPhone registerForRemoteNotificationTypes不会产生一个错误,但不火的委托,让设备令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个需要推送通知的iPhone应用程序。我跟着用于创建认证和修改应用程序ID的说明。我不能完全确定我没有这样做,但我没有按照指示。任何想法我怎么能检查,看看这是否正常?

当我在模拟器中我没有得到一个错误信息说,该仿真器不支持推送通知跑去。这是有所预期的。

BTW:我好像有这个问题,在那里几次。它似乎总是与监狱破碎手机。我的手机是不是监狱破碎。

但是,当我调试iPhone上的didRegisterForRemoteNotificationsWithDeviceToken方法从未被触发过。我真的会AP preciate一些帮助。我的code如下:

   - (空)的applicationDidFinishLaunching:(UIApplication的*)的应用
{
   rootController.delegate =自我;
   [窗口addSubview:rootController.view];
   [窗口makeKeyAndVisible]   [UIApplication的sharedApplication]
   registerForRemoteNotificationTypes:
   (UIRemoteNotificationTypeAlert |
     UIRemoteNotificationTypeBadge |
     UIRemoteNotificationTypeSound)];
} - (无效)应用:(*的UIApplication)应用didRegisterForRemoteNotificationsWithDeviceToken:(NSData的*)deviceToken
{
   * NSString的海峡=
    [的NSString stringWithFormat:@%@,deviceToken]
    的NSLog(STR);
} - (无效)应用:(*的UIApplication)应用didFailToRegisterForRemoteNotificationsWithError:(NSError *)错误
{
    * NSString的海峡= [的NSString stringWithFormat:@错误:%@,犯错]
    的NSLog(STR);
}


解决方案

通常,如果 didRegisterForRemoteNotificationsWithDeviceToken 不会被调用,那是因为你使用的是供应配置文件不是 APS-题为。如果你的应用程序是一个生产应用程序,它必须与分布配置文件签署推送工作。如果它是一个开发应用程序,你必须用发展概况签字。

编辑:这也是值得一提的是,供应简介必须使用显式的绑定ID。推送到一个通配符的个人资料将不会传递任何签署

I am developing an iPhone app that needs push notification. I followed the instructions for creating the certifications and modifying the app ID. I am not totally sure I did this correctly, but I did follow the directions. Any idea how I can check to see if this is OK?

When I ran in the emulator I did get an error message saying that the emulator did not support push notifications. This was somewhat expected.

BTW: I have seem this question out there a few times. It always seems to be with a jail-broken phone. My phone is NOT jail-broken.

But when I debug on the iPhone the didRegisterForRemoteNotificationsWithDeviceToken method is never fired off. I will really appreciate some help. My code follows.

-(void)applicationDidFinishLaunching:(UIApplication *)application 
{    
   rootController.delegate = self;
   [window addSubview:rootController.view];
   [window makeKeyAndVisible];

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

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken 
{ 
   NSString *str = 
    [NSString stringWithFormat:@"%@",deviceToken];
    NSLog(str);
}

- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err 
{ 
    NSString *str = [NSString stringWithFormat: @"Error: %@", err];
    NSLog(str);    
}

解决方案

Usually if didRegisterForRemoteNotificationsWithDeviceToken is never called, it is because you are using a provisioning profile that is not APS-entitled. If you app is a production app, it must be signed with a distribution profile for pushes to work. If it is a development app, you must sign it with a development profile.

EDIT: It is also worthy to note that the provisioning profile must use an explicit bundle id. Pushes sent to anything signed with a wildcard profile will not be delivered.

这篇关于iPhone registerForRemoteNotificationTypes不会产生一个错误,但不火的委托,让设备令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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