如何将ios设备令牌提供给AWS Pinpoint

时间:2018-04-19 17:57:21

标签: ios token aws-pinpoint

我无法使用AWS Pinpoint控制台执行Direct Messaging。每次尝试都会导致"无法向...提交推送通知。错误我是提供EndpointID还是DeviceToken。我猜测我没有提供有效的设备令牌。

在iOS上,deviceToken作为NSData对象提供。我可以使用[deviceToken description]将它作为字符串打印到控制台。这是我粘贴到Direct Message控制台的字符串(修剪尖括号和内部空间字符后)。这是从本机deviceToken为AWS消息传递生成字符串的预期方法吗?我的另一个猜测,[[NSString alloc] initWithData:deviceToken encoding:NSUTF8StringEncoding],返回nil。

2 个答案:

答案 0 :(得分:0)

通常我会这样做:

deviceToken.map { String(format: "%02.2hhx", $0) }.joined()

但在检查AWS文档网站后,他们基本上是打印设备令牌并删除空格。

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken 
{
    NSLog(@"deviceToken: %@", deviceToken); 
}

请查看本网站: Getting Started with Apple Push Notification Service

答案 1 :(得分:0)

MIDDLEWARE = [ # 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', # ... ] 对象已经包含一种可以轻松实现此目的的方法

  

deviceToken.toHexString()

相关问题