Last active
May 31, 2017 05:52
-
-
Save st0326s/aed49b30d88019a18d385e292176a895 to your computer and use it in GitHub Desktop.
デバイストークン取得(Unity) ref: http://qiita.com/satotin/items/6e513a8945d5ca285188
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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