Dynamic Notification Interface will only work if t

2019-03-26 02:31发布

问题:

Currently there are 3 flavors of notifications in the Apple Watch:

  • Short - You can't customize these at all.
  • Static - You can customize these on the Storyboard.
  • Dynamic - Can customize UI elements with new data not coming on the Notification payload.

Here's the problem (The project is using Watch OS 1), if the app was never opened from the Apple Watch the Static notification will be displayed instead of the Dynamic one and the log will show the error

Took too long to show custom notification. Falling back to static

I've stripped down the notifications code & ViewController to nothing but this:

-(void)didReceiveRemoteNotification:(NSDictionary *)remoteNotification withCompletion:(void (^)(WKUserNotificationInterfaceType))completionHandler 
    {
        completionHandler(WKUserNotificationInterfaceTypeCustom); 
    }

And I was still getting this error.

I must clarify that after the app runs from the watch at least once every thing is working as expected and Dynamic Notification Interface are displayed fine.

Things i've double checked:

  • Watch battery is above 70%
  • This is the only code in my didReceiveRemoteNotification
  • WKUserNotificationInterfaceController subclass is connected to the Dynamic interface Controller in my storyboard file

I've searched the Apple docs for something that verify this behavior and couldn't find anything related. At first I thought that something was not configured correctly with my app but then discovered that this is common in all Apple watch apps i've tried.

Steps to reproduce:

  1. Download an Apple watch app that was never installed on your device and that uses Dynamic notifications. (I've tested this on Telegram and Outlook for example)
  2. Don't open the app from the watch, only from your phone.
  3. send your self a push notification.
  4. The notification will arrive to your watch as Static notification and the Devices log will show the "Took too long to show custom notification. Falling back to static" error.
  5. Open the app from the watch and send another notification. This will arrive as Dynamic.

After the Watch app is opened at least once the above is very hard to reproduce. Deleting the app from phone & watch and reinstalling everything still displayed Dynamic notifications as it should.

Is anyone experienced that?

Is there a way to display dynamic notifications without opening the app at least once on the watch?