Can I use push notifications in a standalone iMessage App?

I have seen responses about iMessage Extensions https://forums.developer.apple.com/message/185071#185071, but if I understand correctly, an iMessage App is different from an iMessage Extension. https://developer.apple.com/imessage/


In the official push notifcations documentation https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/SupportingNotificationsinYourApp.html#//apple_ref/doc/uid/TP40008194-CH4-SW1, it never speaks to push notfications being disabled in an iMessage App and often speaks to how they are possible in extensions (it feels like they only mean watch app extensions?).


I find this very confusing. In my testing, the call to requestAuthorization does display a push notifications pop up, but whether I click Allow or Don't Allow, it always returns false with a nil error. Shouldn't it have an error that says "not supported in iMessage App" as well as an explicit statement in the local and remote notifications documentation that this feature is not allowed?


let center = UNUserNotificationCenter.current()

     center.requestAuthorization(options: [.alert]) { (granted, error) in
   
     // Enable or disable features based on authorization.   
     if(error != nil)   
     {
          print(error.debugDescription)
     }
   
     print("Perm granted", granted)
}

Replies

Are you testing on a simulator or device?


Is your iMessage app enabled for notifications in Settings?

I'm having the exact same issue. I want to add a local notification directly from the messages extension (without a host app), but when I run the above code it never grants permission nor does it give an error.

Please file an ehancement request at https://bugreport.apple.com


In order to utilize APNs (Apple Push Notification service) you must register your device's token which is given (if successful) in a callback via the AppDelegate. iMessage Apps do not conform to the UIApplicationDelegate protocol because the UIApplication shared instance is unavailable to iMessage targeted apps.