I use client API GetPlayerProfile to find out if the player has already enabled push notifications:
bool pushenabled = false; var result = await PlayFabClientAPI.GetPlayerProfileAsync(new PlayFab.ClientModels.GetPlayerProfileRequest() { PlayFabId = playfabid, ProfileConstraints = new PlayFab.ClientModels.PlayerProfileViewConstraints { ShowPushNotificationRegistrations = true } }); if (result.Error != null) { } else { if (result.Result.PlayerProfile.PushNotificationRegistrations[0] != null) pushenabled = true; }
After that, I call client API RegisterForIOSPushNotificationAsync/AndroidDevicePushNotificationRegistrationAsync if push notifications are not enabled.
Is it possible that the player has more than one device enabled for push notifications in result.Result.PlayerProfile.PushNotificationRegistrations?
What can I do if the player has already one iOS device enabled for push notifications and when the player uses a new device to login?
In this case, PushNotificationRegistrations[0] won't be null but the player won't get push notifications on his new device because I haven't called RegisterForIOSPushNotificationAsync/AndroidDevicePushNotificationRegistrationAsync on his new device because PushNotificationRegistrations[0] wasn't null.
Should I always call RegisterForIOSPushNotificationAsync/AndroidDevicePushNotificationRegistrationAsync when the player logs in, even if PushNotificationRegistrations[0] is not null?