didRegisterForRemoteNotificationsWithDeviceToken timing out



  • (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    NSString *deviceTokenStr = [backendless.messagingService deviceTokenAsString:deviceToken];
    NSLog(@"-> deviceToken = %@", deviceTokenStr);

    @try {
    NSString *deviceRegistrationId = [backendless.messagingService registerDeviceToken:deviceTokenStr];
    NSLog(@"-> registerDeviceToken: deviceRegistrationId = %@", deviceRegistrationId);
    }
    @catch (Fault *fault) {
    NSLog(@"-> registerDeviceToken: FAULT = %@", fault);
    }
    }

I’m using the above code to start a process where the app queries backendLess for any new objects for a given table based on “created” field.

Recently my app has been hanging at launch for 30 seconds or more and then kicking out the following message on the console:

(-[AppDelegate application:didRegisterForRemoteNotificationsWithDeviceToken:]) (AppDelegate.m:192) -> registerDeviceToken: FAULT = FAULT = ‘-1001’ [NSURLErrorDomain] <The request timed out.>

and then proceeding with App Launch - when I do a push notification to the app in background it works but that I presume is because I am testing and the app has previously registered for push notifications. Obviously this is not a cool user experience, i.e. waiting an additional 30-45 seconds for the app to launch. Is there some maintenance going on at BackendLess?

Is there someway to put the try-catch statement off of the main loop? Is this how you normally do it? Thank you - I’m going to check the examples

The documentation says: should I implement it this way?

  • (void)application:(UIApplication )app didRegisterForRemoteNotificationsWithDeviceToken:(NSData)deviceToken { [backendless.messaging registerDeviceToken:deviceToken];}


Hi Roberto,

Please investigate this sample.

Regards,
Slava

Thank you Slava - I removed the Try/Catch structure as per the sample you pointed to and it worked very well. Thank you for your prompt reply on a Sunday!!!