I'm trying to get push notifications working on iOS (title E8F4). I had no issues registering our title using the .pem file. Here is the class I use in Unity:
using UnityEngine; using System.Collections; using PlayFab; using PlayFab.ClientModels; public class PlayFabController : MonoBehaviour { public string titleId; bool tokenReceived = false; void Start() { PlayFabSettings.TitleId = titleId; StartCoroutine(RegisterForPushNotifications()); } IEnumerator RegisterForPushNotifications() { #if UNITY_IOS UnityEngine.iOS.NotificationServices.RegisterForNotifications(UnityEngine.iOS.NotificationType.Alert | UnityEngine.iOS.NotificationType.Badge | UnityEngine.iOS.NotificationType.Sound, true); WaitForSeconds oneSec = new WaitForSeconds(1f); while (!tokenReceived) { byte[] token = UnityEngine.iOS.NotificationServices.deviceToken; if (token != null) { RegisterForIOSPushNotificationRequest request = new RegisterForIOSPushNotificationRequest(); request.DeviceToken = System.BitConverter.ToString(token).Replace("-", "").ToLower(); PlayFabClientAPI.RegisterForIOSPushNotification(request, (RegisterForIOSPushNotificationResult result) => { Debug.Log("Push Registration Successful"); }, (error) => { Debug.Log("Push Registration Failed with error: " + error.ErrorMessage); }); tokenReceived = true; } yield return oneSec; } #endif yield return null; } }
When users start the app, they are prompted as expected to give permission. However, I've made a segment with the conditions "Push notifications enabled with ApplePushNotificationService" and the count is 0.
What am I missing?
Thanks!