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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Mobile Notificatons working on Android, but not Ios

Discussion in 'Scripting' started by gezapp, Aug 4, 2022.

  1. gezapp

    gezapp

    Joined:
    Apr 18, 2014
    Posts:
    20
    Hello, I'm having some issues regarding the usage of the Unity Mobile Notifications native plugin. I implemented my solution both for Android and Ios, and for Android it works fine. However, for Ios i'm having issues showing the notification to the user.

    It seems the notification, once created, is scheduled just fine, but doesn't show the badge on top of the screen, neither produces any notification sound.

    By reading the documentation in https://docs.unity3d.com/Packages/com.unity.mobile.notifications@1.2/manual/index.html#ios, ios requires permission from the system to push local notifications. However, even by requiring authorization (set in Project Manager) for notifications they won't show up.

    Any ideas?
    Thanks.
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,642
    Do you have Provisional authorisation enabled? That one is automatically approved by OS and means that notifications will work silently. You need to ask user permission without it, then dialog will show up and if approved, notifications will work.
     
  3. gezapp

    gezapp

    Joined:
    Apr 18, 2014
    Posts:
    20
    Yes, Provisional authorisation is enabled. Our App make also use of OneSignal plugin for push notifications and this one works also in ios.
    I forgot to mention that Mobile Notifications is used mainly for local notifications.
     
  4. PixelFireXY

    PixelFireXY

    Joined:
    Nov 2, 2011
    Posts:
    53
    Bump, I would like to know it too, please.
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,642
    If you want notifications to actually appear on screen, you have to request notification permission without provisional flag set.
    Otherwise they work silently (your application receives info about them, but no visual to the user).
     
  6. gezapp

    gezapp

    Joined:
    Apr 18, 2014
    Posts:
    20
    I started a new project to test out the solution you proposed and still the notifications won't show up. These are the settind I use, Push notifications and Core Location are disabled as shown in the screenshot.
     

    Attached Files:

    nahuuy likes this.
  7. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,642
    Does the request for permission dialog show up?
     
  8. gezapp

    gezapp

    Joined:
    Apr 18, 2014
    Posts:
    20
    Yes.
     
  9. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,642
    Well, if it shows up and you allow notification, they should work. The only thing to note here is that notification has
    ShowInForeground property. If it is set to false, notifications will only show up while app is in background.
     
  10. gezapp

    gezapp

    Joined:
    Apr 18, 2014
    Posts:
    20
    This is a code snipped I use for creating an iOS Notification (borrowed from the example project imported from the plugin)
    Code (CSharp):
    1.  public iOSGameNotification()
    2.         {
    3.             internalNotification = new iOSNotification
    4.             {
    5.                 ShowInForeground = true
    6.             };
    7.         }
    ShowInForeground property is by default set to true.
     
  11. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,642
    Can you should full code of how you schedule notification?
     
  12. gezapp

    gezapp

    Joined:
    Apr 18, 2014
    Posts:
    20
    I simply downloaded the sample project, via Unity Package Manager, opened the Demo.scene and built it in XCode. The plugin ver. is 2.0.2 with Unity 2020.3.34f1. The main script to inspect is GameNotificationsManager.