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

Hello,

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

Hi @samhain323

Unfortunately the current push notification offering does not have the ability to target players directly at this time. You would be able to send requests to a third party API that does offer that feature using Cloud Code.

thanks,

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

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.

AndroidJavaException: java.lang.RuntimeException: Failed to determine Activity to be opened when tapping notification
java.lang.RuntimeException: Failed to determine Activity to be opened when tapping notification
com.unity.androidnotifications.UnityNotificationManager.initialize(UnityNotificationManager.java:119)
com.unity.androidnotifications.UnityNotificationManager.getNotificationManagerImpl(UnityNotificationManager.java:142)
com.unity3d.player.UnityPlayer.nativeRender(Native Method)
com.unity3d.player.UnityPlayer.-$Nest$mnativeRender(Unknown Source:0)
com.unity3d.player.UnityPlayer$F$a.handleMessage(Unknown Source:122)
android.os.Handler.dispatchMessage(Handler.java:102)
android.os.Looper.loopOnce(Looper.java:226)
android.os.Looper.loop(Looper.java:313)
com.unity3d.player.UnityPlayer$F.run(Unknown Source:24)
UnityEngine.AndroidJNISafe.CheckException () (at <00000000000000000000000000000000>:0)
UnityEngine.AndroidJNISafe.CallStaticObjectMethod (System.IntPtr clazz, System.IntPtr methodID, System.Span`1[T] args) (at <00000000000000000000000000000000>:0)
UnityEngine.AndroidJavaObject._CallStatic[ReturnType] (System.IntPtr methodID, System.Object[] args) (at <00000000000000000000000000000000>:0)
Unity.Notifications.Android.AndroidNotificationCenter.Initialize () (at <00000000000000000000000000000000>:0)
Unity.Notifications.NotificationCenter.Initialize (Unity.Notifications.NotificationCenterArgs args) (at <00000000000000000000000000000000>:0)
FirebasePushNotifications.InitialiseNotificationCenter () (at <00000000000000000000000000000000>:0)
FirebasePushNotifications.ConditionallyInitialise () (at <00000000000000000000000000000000>:0)

Any insight appreciated.