// this should be done with cloud script /// <summary> /// Sends a push notification request to PlayFab. /// </summary> /// <param name="playFabID">Recipient's PlayFab ID.</param> /// <param name="message">Message to send.</param> public void SendPush(string playFabID, string message) { PlayFab.Server.SendPushNotificationRequest request = new PlayFab.Server.SendPushNotificationRequest(); request.Recipient = playFabID; request.Message = message; // PlayFabServerAPI.SendPushNotification(request, OnSendPushNotificationSuccess, OnSendPushNotificationError); }
/// <summary> /// Sends an iOS/Android Push Notification to a specific user, if that user's device has been configured for Push Notifications in PlayFab. If a user has linked both Android and iOS devices, both will be notified. /// </summary> public static void SendPushNotification(SendPushNotificationRequest request, SendPushNotificationCallback resultCallback, ErrorCallback errorCallback) { if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method"); string serializedJSON = JsonWriter.Serialize (request, Util.GlobalJsonWriterSettings); Action<string,string> callback = delegate(string responseStr, string errorStr) { SendPushNotificationResult result = null; PlayFabError error = null; ResultContainer<SendPushNotificationResult>.HandleResults(responseStr, errorStr, out result, out error); if(error != null && errorCallback != null) { errorCallback(error); } if(result != null) { if(resultCallback != null) { resultCallback(result); } } }; PlayFabHTTP.Post(PlayFabSettings.GetURL()+"/Server/SendPushNotification", serializedJSON, "X-SecretKey", PlayFabSettings.DeveloperSecretKey, callback); }