0

I'm facing an issue after updating my app. I'm getting a device token in this format C43461D5-E9CB-4C10-81F8-020327A07A62 and the notifications aren't working.

Before, I had a notification in this format: 2add70865401171c7ca1d3b3957b719eaf721fef8f8d7a52bc91ef8a872cc004

I did allow notifications for the app and I've not changed anything in the backend. Can anyone guide me why it's not working?

Code in didFinishLaunchingWithOptions:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}

Getting the device token:

NSString *deviceTokenID = [[NSUserDefaults standardUserDefaults] objectForKey:DEVICE_TOKEN_PUSH_NOTI];
if ([deviceTokenID isEqualToString:@""] || deviceTokenID == nil) {
    NSString *tempApplicationUUID  = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    [dics setObject:tempApplicationUUID forKey:@"cust_device_id"];
} else {
    [dics setObject:[[NSUserDefaults standardUserDefaults] objectForKey:DEVICE_TOKEN_PUSH_NOTI] forKey:@"cust_device_id"];
}

I got the below error:

Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo={NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}, no valid 'aps-environment' entitlement string found for application

ricardopereira
  • 11,118
  • 5
  • 63
  • 81
Naushad Qamar
  • 123
  • 3
  • 14
  • can you show ur code of didfinishlaunch – Anbu.Karthik Oct 13 '16 at 10:35
  • also show your code of getting device token. – ashmi123 Oct 13 '16 at 10:36
  • "if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; [[UIApplication sharedApplication] registerForRemoteNotifications]; } else { [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)]; }" – Naushad Qamar Oct 13 '16 at 10:36
  • Show your code of getting device token and show it in your code please not in comment. – ashmi123 Oct 13 '16 at 10:38
  • how you take device token? – ashmi123 Oct 13 '16 at 10:39
  • http://stackoverflow.com/questions/39990629/sskeychain-not-retain-data/39992564#39992564 refer my answer – Himanshu Moradiya Oct 13 '16 at 10:41
  • I have updated the question please check – Naushad Qamar Oct 13 '16 at 10:48
  • check your provisional profile and check the server side which ssl certificate they are using. – balkaran singh Oct 13 '16 at 10:49

3 Answers3

3

enter image description here

plz go to

Click on .xcodeproj -> Capabilities -> Enable Push Notification

hope it's work

balkaran singh
  • 2,754
  • 1
  • 17
  • 32
1

Click on .xcodeproj -> Capabilities -> Enable Push Notification

enter image description here

ashmi123
  • 710
  • 1
  • 6
  • 21
  • @Jack this is just used for background modes of push notifications. It has nothing to do with why push notif doesn't come. In short this is **NOT** used to **Enable** push notif. This is just used to handle notifications in background mode – Rajan Maheshwari Oct 13 '16 at 13:41
  • @RajanMaheshwari this ans is related to error get. So i just give ans for that error "no valid 'aps-environment' entitlement string found for application". – ashmi123 Oct 14 '16 at 02:48
-3
NSString *tempApplicationUUID  = [[[UIDevice currentDevice] identifierForVendor] UUIDString];

The UUIDString is the Unique device ID but for the Apple Push Notification you required the device token get back from APNS so for that Use the below method you get 64 digit deviceToken and get notification.

-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken


{
    NSString *devToken = [[[[deviceToken description]
                            stringByReplacingOccurrencesOfString:@"<"withString:@""]
                           stringByReplacingOccurrencesOfString:@">" withString:@""]
                          stringByReplacingOccurrencesOfString: @" " withString: @""];


    NSString *str = [NSString
                     stringWithFormat:@"Device Token=%@",devToken];

    [[NSUserDefaults standardUserDefaults]setObject:devToken forKey:@"DeviceToken"];

}
Darshan Kunjadiya
  • 3,323
  • 1
  • 29
  • 31
ashmi123
  • 710
  • 1
  • 6
  • 21