I am trying to implement push notification in app.
I have done that for ios 8. on iPad OS is ios8. I got push notification on iPad.
on iPhone OS is iOS7. whenever I compile app on iPhone I got error
/* Failed to get token, error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x16d246c0 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}*/
My app delegate methods are
- (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);
}
Appreciate for help
2 Answers 2
The message indicates you are using a different signing certificate for iPad/iOS 7 than for iPhone/iOS 8, one without the permission for push notifications set. It has nothing to do with your code.
Comments
Sounds like your app is picking up the wrong provisioning profile for whatever reason. Does it start working if you explicitly specify the provisioning profile?