我正在执行Unity的
Notification Service
我认为我的实现没有问题。
我是这样注册的:
NotificationServices.RegisterForNotifications(NotificationType.Badge |
NotificationType.Alert | NotificationType.Sound, true);
我的功能中还启用了推送通知。
获取我使用的设备令牌
NotificationServices.deviceToken
.
DeviceToken的问题是它返回一个
byte[]
我尝试了几种方法,但唯一能让我可读的方法是:
byte[] token = NotificationServices.deviceToken;
Debug.Log(System.BitConverter.ToString(token).Replace("-", ""));
Debug.Log(Convert.ToBase64String(token));
-
第一个方法返回我:
348CDFAE308F9107A3DB0807CC363BBB01DEC33008E9F474A9A81D57D039D245
,如果没有替换
34-8C-DF-AE-30-8F-91-07-A3-DB-08-07-CC-36-3B-BB-01-DE-C3-30-08-E9-F4-74-A9-A8-1D-57-D0-39-D2-45
-
第二个方法返回我:
cFXd3wLN0aCOpx7vn9pwDlJ24W32m9WO3A+WY28G4Zs=
,这里是有趣的部分,如果我修改Unity在编译时生成的方法
didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
NSString *token;
token = [deviceToken description];
NSLog(@"Token: %@", token);
我得到以下结果:
Token: <7055dddf 02cdd1a0 8ea71eef 9fda700e 5956e16d 8e9bd54e dc0f9263 6f03e19b>
我尝试用我所有的令牌发送推送通知,但没有一个有效。
来自Unity
,如何正确解码deviceToken以发送推送通知?
谢谢=)