我使用以下代码在AWS SNS中注册设备(Windows Phone)作为应用程序中的端点
uv
创建端点时,它会抛出错误请求中包含的安全令牌无效,同时执行代码
/**
* @return A comma separated list of radios that need to be disabled when airplane mode is on
*/
private String getGlobalSettingValues() {
ContentResolver cr = getContentResolver();
Cursor globalCursor = null;
String aeroplaneMode = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
globalCursor = cr.query(Settings.Global.CONTENT_URI, null, null, null, null);
if(globalCursor != null && globalCursor.moveToFirst()){
aeroplaneMode = Settings.Global.getString(getApplicationContext().getContentResolver(),Settings.Global.AIRPLANE_MODE_RADIOS);
}
}
if (globalCursor != null) {
globalCursor.close();
}
return aeroplaneMode;
}
请帮助我实现这一目标。提前致谢
答案 0 :(得分:0)
使用以下代码在AWS SNS应用程序中注册Windows Phone设备。我可以使用以下代码创建端点。
private async void Push()
{
CognitoAWSCredentials cognitoProvider = new CognitoAWSCredentials(UserId,
IdentitypoolID,
UnAuthRoleARN,
AuthRoleARN,
Region);
using (var sns = new AmazonSimpleNotificationServiceClient(credentials, RegionEndpoint.USEast1))
{
var channelOperation = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
CreatePlatformEndpointRequest epReq = new CreatePlatformEndpointRequest();
epReq.PlatformApplicationArn = "PlatformApplicationARN";
epReq.Token = channelOperation.Uri.ToString();
CreatePlatformEndpointResponse epRes = await sns.CreatePlatformEndpointAsync(epReq);
CreateTopicRequest tpReq = new CreateTopicRequest();
SubscribeResponse subsResp = await sns.SubscribeAsync(new SubscribeRequest()
{
TopicArn = "TopicARN",
Protocol = "application",
Endpoint = epRes.EndpointArn
});
channelOperation.PushNotificationReceived += ChannelOperation_PushNotificationReceived;
}
}