We have Cordova Android/iOS apps. On iOS, we're using XCode 10 and targeting iOS 10, and we use the urbanairship-cordova plugin. There is a quirk I am struggling with on iOS.
When I log into the app my named user is set in Airship. The device shows up fine on device lookup, and appears as opted out for notifications. Thats fine, because we have a preferences page where the user can enable mobile notifications. On that page, we use the `setUserNotificationsEnabled` method of the cordova plugin to update the enabled value. Calling this method brings up the native prompt to allow notifications. Once the user allows notifications, we receive the `notification_opt_in_status` document event, but back in the Airship device lookup dashboard the device is still listed as opted out.
We notice that if we close and reopen the app at this point, the device is marked as opted-in and we can push notifications as normal. This is only an issue on iOS.
Here are the logs from a first app run right after a fresh installation. All i did during this run was open the app, log in, enable notifications, and close the app. My device was successfully registered on Airship (Dev Project), but the device was not opted in even though I enabled notifications.
https://s3.amazonaws.com/respage-temp/first+app+launch+logs.txt
Here are the logs for the very next run. By the time the app finishes loading, my device is marked as opted-in on the Airship dashboard
https://s3.amazonaws.com/respage-temp/second+app+launch+logs.txt
Note: Any lines that contain "[URBAN AIRSHIP]" are debugging lines added by us. I replaced our actual Development API Key with "[DEVELOPMENT API KEY]" placeholder everywhere in the logs.
Comments
2 comments