Version: 2017.3

NotificationServices.RegisterForNotifications

Switch to Manual
public static void RegisterForNotifications (iOS.NotificationType notificationTypes);
public static void RegisterForNotifications (iOS.NotificationType notificationTypes, bool registerForRemote);

Parameters

notificationTypes Notification types to register for.
registerForRemote Specify true to also register for remote notifications.

Description

Register to receive local and remote notifications of the specified types from a provider via Apple Push Service.

After an application registers for the specified remote notification types, the device token is received from Apple Push Service and is available via NotificationServices.deviceToken.

using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
using NotificationServices = UnityEngine.iOS.NotificationServices;
using NotificationType = UnityEngine.iOS.NotificationType;

public class NotificationRegistrationExample : MonoBehaviour { bool tokenSent;

void Start() { tokenSent = false;

NotificationServices.RegisterForNotifications( NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); }

void Update() { if (!tokenSent) { byte[] token = NotificationServices.deviceToken; if (token != null) { // send token to a provider string hexToken = "%" + System.BitConverter.ToString(token).Replace('-', '%'); UnityWebRequest.Get("http:/example.com?token=" + hexToken).SendWebRequest(); tokenSent = true; } } } }