Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Resolved Can you send mobile push notifications to specific users from cloud code

Discussion in 'Cloud Code' started by samhain323, May 31, 2024.

  1. samhain323


    Aug 4, 2020

    I have mobile push notifications set up and working with the test from the dashboard. I also have the sending of player messages from cloud code working (i.e. SendPlayerMessageAsync).

    What I want is to be able to use UGS to send mobile push notifications from cloud code (or from a trigger if that's not possible). I can't figure out how to send push notifications from Cloud Functions like I can player messages.

    Is there any way to do this?

    I have a turn based game, and one of the things I use the notifications for is to let a player know when their opponent has moved. I was using playfab and Azure to do this previously. Whenever a player would move, I would send a mobile push notification to the opponent via Azure functions. I'm not sure how to do this with UGS.

    Any help would be appreciated
  2. samg-unity


    Unity Technologies

    Mar 23, 2021
  3. samhain323


    Aug 4, 2020

    I was able to get firebase messaging to work. Can't wait till UGS implements it, this is the last bit of non unity services I need to get rid of
  4. nmckean


    Apr 12, 2020
    I am also trying to get Firebase Messaging to work with UnityMobileNotifications. I mainly use Unity package to get the Push Notification Status and am using Firebase to send Push Notifications and receive on the client.

    My issue though is a conflict between Activities. Firebase ordinarily overrides the UnityPlayerActivity with MessagingUnityPlayerActivity. I assume they need to be the same when using both packages and so used the custom activity function in UnityMobile notifications to point to MessagingUnityPlayerActivity and after another failure even copied the androidmanifest.xml that FirebaseCloudMessaging uses.

    Whatever I do I keep getting the error.
    Code (CSharp):
    1. AndroidJavaException: java.lang.RuntimeException: Failed to determine Activity to be opened when tapping notification
    2. java.lang.RuntimeException: Failed to determine Activity to be opened when tapping notification
    3. com.unity.androidnotifications.UnityNotificationManager.initialize(
    4. com.unity.androidnotifications.UnityNotificationManager.getNotificationManagerImpl(
    5. com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    6. com.unity3d.player.UnityPlayer.-$$Nest$mnativeRender(Unknown Source:0)
    7. com.unity3d.player.UnityPlayer$F$a.handleMessage(Unknown Source:122)
    8. android.os.Handler.dispatchMessage(
    9. android.os.Looper.loopOnce(
    10. android.os.Looper.loop(
    11. com.unity3d.player.UnityPlayer$ Source:24)
    12. UnityEngine.AndroidJNISafe.CheckException () (at <00000000000000000000000000000000>:0)
    13. UnityEngine.AndroidJNISafe.CallStaticObjectMethod (System.IntPtr clazz, System.IntPtr methodID, System.Span`1[T] args) (at <00000000000000000000000000000000>:0)
    14. UnityEngine.AndroidJavaObject._CallStatic[ReturnType] (System.IntPtr methodID, System.Object[] args) (at <00000000000000000000000000000000>:0)
    15. Unity.Notifications.Android.AndroidNotificationCenter.Initialize () (at <00000000000000000000000000000000>:0)
    16. Unity.Notifications.NotificationCenter.Initialize (Unity.Notifications.NotificationCenterArgs args) (at <00000000000000000000000000000000>:0)
    17. FirebasePushNotifications.InitialiseNotificationCenter () (at <00000000000000000000000000000000>:0)
    18. FirebasePushNotifications.ConditionallyInitialise () (at <00000000000000000000000000000000>:0)
    Any insight appreciated.