I am trying to create platform endpoint in amazon sns
from the console.
Below is the device token which I received from FCM/APNs
:
fUG5dIcN_pA:APA91bEciRwWuvTIezAKcJ5y1xz5z6BygE3YJkywdCGCFJD93NTfjARwPRommwgsfvVo2iH_qZWT7D2Lxnc69uanato1UUq-nLl5R1L0qF4exT7zjM9Wdy9Evs6h-EOBtIVv7Vv8bPE1
I am getting an error: iOS device tokens must be no more than 400 hexadecimal characters.looks like APNs has sent token in string format and Amazon is expecting it in hexadecimal chars.
Try the below code in didRegisterForRemoteNotificationsWithDeviceToken
:
let deviceToken = deviceToken.map {String(format:"%02.2hhx",$0)}.joined()
print(deviceToken)
And Paste the device token in amazon SNS console, it will work.
For objective-c you can use this:
NSString * deviceTokenString = [[[[deviceToken description]
stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
NSLog(@"The generated device token string is : %@",deviceTokenString);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With