Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Mobile Notifications 2.0.0 update broke local notifications on iOS

Discussion in 'iOS and tvOS' started by tarmo-jussila, Apr 23, 2022.

  1. tarmo-jussila

    tarmo-jussila

    Joined:
    Jun 4, 2015
    Posts:
    42
    We ended up updating the Mobile Notifications package to 2.0.0 because the previous version clashed hard with Firebase plugins and caused black screens and crashes on iOS 15. There's a thread about the issue and solution in GitHub (which is now closed). Updating to Mobile Notifications 2.0.0 solved the crash issue, but came with new ones. Specifically, the local notifications do not seem to function on any iOS version anymore as intended. So we fixed the crash but lost the functionality of notifications - a bad tradeoff. For Android everything is working exactly the same as before, so this is iOS-specific.

    I am wondering what might be causing the lack of local notifications on iOS after the update? We did update to Xcode 13.2.1, too, as it's now required by Apple. Previously we were using Xcode 12.4.0. But it seems the lack of local notifications started right after updating the Mobile Notifications package. We are not seeing any errors in the log and we even see log prints about the scheduling of notifications, they just don't show up.

    Has anyone else faced the same issues on iOS?
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,463
    Notification do work, there must be something with your project.
    One thing that could possibly cause it is provisional authorization, which we started to support in new release. If you request permission to send notifications with provisional auth, you are immediately granted, but notifications work silently (app does get them, but user sees nothing). To show user visible notifications, you have to request permission without provisional.
     
  3. tarmo-jussila

    tarmo-jussila

    Joined:
    Jun 4, 2015
    Posts:
    42
    Hello. What you're describing sounds like it could match the current behaviour. I do request the permission to send local notifications in the beginning of the app. I was not aware of this provisional permission change. I will have to look into it. Thank you!
     
  4. jgmakes

    jgmakes

    Joined:
    Jan 10, 2019
    Posts:
    75
    This Apple doc seems to imply that the Provisional Authorization option needs to be set and called explicitly, so it would be kind of surprising if this happened to you without you explicitly adding the option.
     
  5. tarmo-jussila

    tarmo-jussila

    Joined:
    Jun 4, 2015
    Posts:
    42
    You're probably right. This is not the case. Something else has changed in the setup which causes our notifications to fail silently on iOS.

    So this issue remains unsolved.
     
  6. tarmo-jussila

    tarmo-jussila

    Joined:
    Jun 4, 2015
    Posts:
    42
    It seems there's a new log message visible in Xcode on version 13.2.1 when backgrounding the app. I haven't noticed this before.

    Code (CSharp):
    1. unregister notification for write_timeout failed
    It seems this might be related to our specific setup since we got both Firebase and Mobile Notifications in the app.

    Still no solution to fix it.
     
  7. jgmakes

    jgmakes

    Joined:
    Jan 10, 2019
    Posts:
    75
    I have both Firebase + FCM installed as well, and am not getting any notifications via Mobile Notifications. Today I'm going to try ripping out FCM to see if local notifications work. For our project, local notifications are more valuable.
     
  8. DinHammer

    DinHammer

    Joined:
    Sep 9, 2018
    Posts:
    7
    I have same problem with ios local mobile notifications, have any idea what to do?
     
  9. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,463
    Do you explicitly ask for permission anywhere in your project?
    If not, do you see permission dialog the first time you launch app?

    If no to both, go to to project settings, open notifications section and check if you have Provisional authorization enabled. Provisional means that notification work silently, that is they are send and delivered to your app, but no user visible UI is shown. If you need to show notification, you have to request authorization without Provisional flag.
     
  10. tarmo-jussila

    tarmo-jussila

    Joined:
    Jun 4, 2015
    Posts:
    42
    Dialog in the beginning is visible. Provisonal flag is not enabled. Notifications are not displayed, but it seems they are sent because they appear in the Unity logs.
     
  11. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,463
    Could you make a simple project that reproduces this and submit a bug report?
    I'd like to have a look at it.
     
  12. DinHammer

    DinHammer

    Joined:
    Sep 9, 2018
    Posts:
    7
    When I downgrade packet to version 1.4.2 it's work fine.
     
  13. dennisjm

    dennisjm

    Joined:
    May 8, 2019
    Posts:
    3
    Sorry for posting on an old thread but this seems most relevant. I'm having trouble with this as well. I've tried Downgrading from 2.x back to 1.4.2 but also no luck. I've double checked everything in this thread with Provisional being unchecked, permissions granted (verified w/ code as well) etc. The notification code runs and notifications are added (it says) but I never receive the notification. Also... works fine on Android. Also, I have Firebase in my project. I don't have any reason to suspect any particular thing as the problem though so I'm curious if anyone has a suggestion how to debug further.
     
  14. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,463
    You mean downgrading didn't solve the problem? That will rule out the Provisional and indicate some other problem with your project, as notifications do work, we test that.
     
  15. dennisjm

    dennisjm

    Joined:
    May 8, 2019
    Posts:
    3
    Yes, thanks for the reply. I did also come to the conclusion it's something else with the project. I'm not sure how to debug what though. I'm not getting any errors or other feedback. I tried looking in the Console for the device and filtering for notification messages but either I'm not finding anything or it's too verbose to find anything useful.
     
  16. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,463
    The starting point would be schedule notification with ShowInForeground set to true and put a breakpoint in UnityNotificationManager.m in a "willPresentNotification" method. You'll have to have your app in the foreground until notification arrives.
     
  17. dennisjm

    dennisjm

    Joined:
    May 8, 2019
    Posts:
    3
    I found the issue. Sometimes it just takes posting on a forum and looking at it again lol.

    My notification Trigger was not being assigned. I created a trigger time but didn't correctly set the notification variable to that time.