1

I updated my app for ios10, and have the requisite changes in place, forking code between ios10 and below to hit proper method calls.

It seems to work properly. I have a specific app sound that tells me the remote push was processed by the app, as if not, the default device sound is used.

Upon install to test device, all is proper. But once and a while and seemingly randomly, I lose app-centric push receipt at my device.My console never shows the push since it is not sent to the phone.

I run IOS Console to watch it and it seems to report that a "completely unknown" token was received. It works on my pre-ios10 device.

I am at a loss for how to determine what is wrong given all works properly at the start.

I am guessing at the moment that my completion handling might not be correct and that iOS10 is punishing my app?

I will edit the question as i can when i get more clue, but at present, this is very troublesome.

Chris Emerson
  • 13,041
  • 3
  • 44
  • 66
drew..
  • 3,234
  • 3
  • 16
  • 19

1 Answers1

0

Did you registered for the Push notification ?

#define SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

if(SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(@"10.0")){
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
     if( !error ){
         [[UIApplication sharedApplication] registerForRemoteNotifications];
     }
 }];  
}

return YES;
}

Did you implemented for the below delegate methods ?

-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler{

//Called to let your app know which action was selected by the user for a given notification.

NSLog(@"Userinfo %@",response.notification.request.content.userInfo);

}

And can you check this thread for more clue

iOS 10 and 9 follows different payload structure.

The iOS 10 follows

 {
        "aps":{
            "alert":{
                "body":"YOUR_MESSAGE."
            },
            "badge":1
        },
        “YOUR_VARIABLE” : "YOUR VALUE"
    }

where iOS < 9 follows

{
    “aps” :     {
        “alert” : "YOUR_MESSAGE.”,
        “badge” : 1,
        “sound” : “default”
    },
    “YOUR_VARIABLE” : "YOUR VALUE"
}

I thing this might be the issue

Community
  • 1
  • 1
radkrish
  • 130
  • 1
  • 15
  • yes. As mentioned, upon install, it works perfectly. It is an app that has been through numerous submissions and tested many times. Certs, back-end, and pre-ios10, all good. Post-ios10, good to start but occasionally goes awry. No clue why my independent console tells me of the unknown token and sends it to the device only. I don't have the text of the log anymore but it essentially said: we just got a totally unknown token so we are ignoring it, and sending to the device itself. Nothing in my back-end changed, and the pre-io10 test device is flawless. – drew.. Oct 15 '16 at 05:57
  • i suspect my issue is some subtle combo of missing aps components in my silent pushes and/or not firing off a completion handler. The app is a very complex messaging app and while i *think* i have all the pathways covered, perhaps i am missing something. I had a tough time trying to get silent notifications working in iOS8 and essentially gave up, so perhaps some remnants of my attempts remain. I will walk all the code as best i can to see. I may have to build a shell of a new app with separate certs to test that indeed i can get this rolling correctly, then backtrack. – drew.. Oct 15 '16 at 17:08
  • The issue manifests with every re-debug. I have discovered it resets itself if i turn the device off. So i am going to examine the raw console logs to see if i can see the issue, but may just let it slide until an Xcode update which could resolve things. – drew.. Oct 15 '16 at 23:03
  • Indeed @radkrish.. Last night, I even replaced all my certs again, just in case. No dice. I think i will build a new app from scratch and setup push etc to see where this is failing. Parse.com makes it harder as they create an interim process to the push. I'd prefer creating the raw construct and see it at their platform. Thanks for the patience with the mods while this almost-monologue progresses. – drew.. Oct 16 '16 at 15:35
  • I think this might be the problem [Link](http://www.ibm.com/support/knowledgecenter/SSMRK7_3.0.0/AppPush/Apple_iOS/ios10payloads.html) – radkrish Oct 18 '16 at 10:01
  • Add check my Edit – radkrish Oct 18 '16 at 10:10
  • Thanks for the edits. I checked the provided link (thanks) and it deals with new media-oriented notifications. This is not my case. I have boiled down the issue to the barest use-case. I can install the app via a debug session and it works flawlessly. If i fire it up, and immediately stop it and restart a debug session, that is all it takes for iOS10 to lose track of the token. This does NOT occur in pre-iOS10 devices. There are no error messages in my console, and no issues are apparent. I submitted radar: 28789788 ps: i appreciate your continued presence here as this is perplexing. – drew.. Oct 19 '16 at 16:27