skip to Main Content

I’m trying to create the app that updates the widget when the server sends a push notification.
But I’m not sure if this is possible.
Has anyone developed the app related to this?
If that’s not possible, I’ll try to figure out another way not using push notification.

2

Answers


  1. Chosen as BEST ANSWER

    I was able to trigger the remote notification using the userNotificationCenter(_:didReceive:withCompletionHandler:) and application(_:didReceiveRemoteNotification:fetchCompletionHandler:) methods of UNUserNotificationCenterDelegate.

    What exactly I wanted was to change the widget in real time when a silent push came.

    However, according to Apple's official documentation...

    Because silent push has limitations (1. number per hour limit, 2. Possibility not to be delivered), it was difficult to update the widget in real time.

    So my conclusion is,

    It is possible to update the widget using remote notification, but it is difficult to use it in a way that updates the widget in real time in the background.


  2. The suitable solution is to start a CLLocationManager in the background.

    Ref: https://developer.apple.com/documentation/corelocation/getting_the_user_s_location/handling_location_events_in_the_background

    After that, your app can run in the background to execute codes (without user terminates/kills it).
    Then you can apply a Real-time event listener to refresh Widget info.

    You can reduce the accuracy and increase distanceFilter to reduce power consumption. It is like you just keep app in background but don’t need Device location data.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search