【发布时间】:2015-06-22 17:49:42
【问题描述】:
我正在尝试在应用中实现推送通知。
我已经为 ios 8 做到了这一点。在 iPad OS 上是 ios8。我在 iPad 上收到推送通知。
在 iPhone 操作系统上是 iOS7。每当我在 iPhone 上编译应用程序时都会出错
/* 获取令牌失败,错误:错误域 = NSCocoaErrorDomain 代码 = 3000 “找不到应用程序的有效 'aps-environment' 权利字符串” UserInfo=0x16d246c0 {NSLocalizedDescription=找不到有效的 'aps-environment' 权利字符串应用程序}*/
我的应用委托方法是
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
// 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);
}
感谢帮助
【问题讨论】:
标签: ios