xcode 推送通知不起作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5027880/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Push Notification is not working?
提问by Piscean
i edit and modify the provisioning profile alot of times. and i checked it in text editor too. everything is ok with provisioning profile. but still push notifications are not working. and i m getting this error. everyone is saying that its bcz of bad provisioning profile but my provisioning profile values are the same as Apple said in their documentation. i m getting this error:
我多次编辑和修改配置文件。我也在文本编辑器中检查了它。配置文件一切正常。但仍然推送通知不起作用。我收到这个错误。每个人都在说它的配置文件错误,但我的配置文件值与 Apple 在他们的文档中所说的相同。我收到此错误:
Error in registration. Error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x127d80 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}
注册错误。错误:错误域=NSCocoaErrorDomain 代码=3000“没有为应用程序找到有效的‘aps-environment’授权字符串” UserInfo=0x127d80 {NSLocalizedDescription=没有为应用程序找到有效的‘aps-environment’授权字符串}
code lookes like this in my AppDelegate.m:
我的 AppDelegate.m 中的代码如下所示:
- (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 {
NSString *deviceTokenStr = [[[[deviceToken description] stringByReplacingOccurrencesOfString: @"<" withString: @""] stringByReplacingOccurrencesOfString: @">" withString: @""] stringByReplacingOccurrencesOfString: @" " withString: @""];
NSLog(@"DeviceTokenStr: %@",deviceTokenStr);
}
Thanx for help in advance
提前感谢帮助
回答by Jon Nadal
I believe the "no valid 'aps-environment' entitlement string found for application" error appears when you don't sign your app with the correct provisioning profile. You'll have to generate a profile for your app as described in Mahesh's link). Also note that you can't use a team provisioning profile to sign an app that requires push notifications.
我相信当您没有使用正确的配置文件签署您的应用程序时,会出现“没有为应用程序找到有效的 'aps-environment' 权利字符串”错误。您必须按照Mahesh的链接 中所述为您的应用程序生成配置文件。另请注意,您不能使用团队配置文件来签署需要推送通知的应用程序。