Launch app in background automatically?

前端 未结 1 909
眼角桃花
眼角桃花 2021-01-17 02:21

Is there a way to persist an iOS app in the background such that it starts up automatically when the device is turned on and will re-launch later if terminated? I have read

相关标签:
1条回答
  • 2021-01-17 02:57

    Yes, you can start your app using APNS.

    1) You have to set "content-available" to 1 in the notification body.

    2) You have to implement:

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

    3) And have the right background modes: Background Modes

    But be careful, your users can turn this off by disabling Background App Refresh in the iPhone Settings. You can check this in code:

    [UIApplication sharedApplication].backgroundRefreshStatus!=UIBackgroundRefreshStatusAvailable
    
    0 讨论(0)
提交回复
热议问题