Skip to content

Instantly share code, notes, and snippets.

@st0326s
Last active May 31, 2017 05:52
Show Gist options
  • Save st0326s/aed49b30d88019a18d385e292176a895 to your computer and use it in GitHub Desktop.
Save st0326s/aed49b30d88019a18d385e292176a895 to your computer and use it in GitHub Desktop.
デバイストークン取得(Unity) ref: http://qiita.com/satotin/items/6e513a8945d5ca285188
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GetToken : MonoBehaviour {
// Use this for initialization
void Start () {
UnityEngine.iOS.NotificationServices.RegisterForNotifications(
UnityEngine.iOS.NotificationType.Alert |
UnityEngine.iOS.NotificationType.Badge |
UnityEngine.iOS.NotificationType.Sound);
}
public void GetTokenString()
{
GetTokenData ();
}
private void GetTokenData ()
{
#if UNITY_IPHONE
string deviceToken = "";
// デバイストークン取得
byte[] token = UnityEngine.iOS.NotificationServices.deviceToken;
if (token != null)
{
deviceToken = System.BitConverter.ToString(token).Replace("-", "");
}
else
{
deviceToken = "Nothing";
}
// ベンダーID取得
string identifierForVendor = UnityEngine.iOS.Device.vendorIdentifier;
Debug.Log("deviceToken=" + deviceToken);
Debug.Log("identifierForVendor=" + identifierForVendor);
#endif
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment