Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

NotificationServices.RegisterForNotifications

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

Cambiar al Manual
public static function RegisterForNotifications(notificationTypes: iOS.NotificationType): void;
public static void RegisterForNotifications(iOS.NotificationType notificationTypes);
public static function RegisterForNotifications(notificationTypes: iOS.NotificationType, registerForRemote: bool): void;
public static void RegisterForNotifications(iOS.NotificationType notificationTypes, bool registerForRemote);

Parámetros

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

Descripción

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.

#pragma strict

public class NotificationRegistrationExample { var tokenSent;

function Start() { tokenSent = false; iOS.NotificationServices.RegisterForNotifications( iOS.NotificationType.Alert | iOS.NotificationType.Badge | iOS.NotificationType.Sound); }

function Update() { if (!tokenSent) { var token = iOS.NotificationServices.deviceToken; if (token != null) { // send token to a provider var hexToken = "%" + System.BitConverter.ToString(token).Replace('-', '%'); new WWW("http:/example.com?token=" + hexToken); tokenSent = true; } } } }
using UnityEngine;
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('-', '%'); new WWW("http:/example.com?token=" + hexToken); tokenSent = true; } } } }