After researching a lot Ive found out that this is a popular problem, but Im posting a new question because none of them was helpful to solve my problem.
Im following this tutorial in order to create Push Notifications for an iOS device.
It look's like everything is working fine, because when I execute the simplepush.php code it returns
Connected to APNS
Message successfully delivered
but the device doesn`t receive any push messages.
A few keypoints:
sandbox server. There`s no messing around with Production issues.And this is how Im getting the token on the AppDelegate.m file:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
return YES;
}
#ifdef __IPHONE_8_0
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
//register to receive notifications
[application registerForRemoteNotifications];
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler
{
//handle the actions
if ([identifier isEqualToString:@"declineAction"]){
}
else if ([identifier isEqualToString:@"answerAction"]){
}
}
#endif
- (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);
}
Token response when launching the app (looks OK to me):
2015-12-03 13:27:27.930 PushChat[598:246912] My token is: 8a0b645c 46c0547a 3078be82 52b4a82d 9b579530 fb9a902d>
Just solved the same issue. In my case the problem had nothing to do with certificates or private key, instead it was related to a wildcard App Id. I have an application bundle wich I use for many business apps, so I have a wildcard app id com.domain.* and a set of provisioning profile associated (development, appstore, adhoc). I knew that in order to use Push Notifications a unique App Id was needed, in fact XCode generated automatically the unique App ID from the wildcard one. But this was not enough: the provisioning profile was still connected to the wildcard App Id. I had to sign the target with a new unique Provisioning Profile (I used the XCode autogenerated one) directly associated with the com.domain.appname unique app id. Definitely, if you want to use push notifications you can't use one provisioning profile for multiple apps, but you had to create a provisioning profile for each app id.
If you plan to use services such as Game Center, In-App Purchase, and Push Notifications, or want a Bundle ID unique to a single app, use an explicit App ID.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With