0

I am using Xcode 11.2.1 and iOS 13.2.2.

I use the method bellow to handle remote notification and it works correctly, but the problem happen when I switch Off the device and switch on again... then insert the pin without opening my app, when I send push, I receive the push but the method bellow not call always, does anybody has the same issue?

this is the payload which I send from server:

{"aps":{"content-available": 1,"alert":"Testing.. (100)","badge":1,"sound":"default"}}

and this is the code when I receive push:

 -(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void
      (^)(UIBackgroundFetchResult))completionHandler
      {

    if( [UIApplication sharedApplication].applicationState == UIApplicationStateInactive )
    {
      NSLog( @"INACTIVE" );
      completionHandler( UIBackgroundFetchResultNewData );
    }
    else if( [UIApplication sharedApplication].applicationState == UIApplicationStateBackground )
    {
      NSLog( @"BACKGROUND" );
      completionHandler( UIBackgroundFetchResultNewData );
    }
    else
    {
      NSLog( @"FOREGROUND" );
      completionHandler( UIBackgroundFetchResultNewData );
    }
    }
Steven
  • 762
  • 1
  • 10
  • 27
  • As apple documentation: The system treats background notifications as low-priority: you can use them to refresh your app’s content, but the system doesn’t guarantee their delivery. In addition, the system may throttle the delivery of background notifications if the total number becomes excessive. The number of background notifications allowed by the system depends on current conditions, but don’t try to send more than two or three per hour. https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app – Moayad Al kouz Nov 21 '19 at 10:41
  • The strange things, I receive the banner that push arrived but not called the delegate, is it normal? when I switch off the device and on again.... but after while it starts call the delegate when is send push... – Steven Nov 21 '19 at 10:47

0 Answers0