如何在Cordova mobile中配置amazon SNS以接收推送通知
我正在使用ionic框架开发Cordova应用程序。我想使用亚马逊sns服务推送通知 我已经在应用程序中为浏览器配置了AmazonSDK。但是如何在Cordova mobile中配置amazon SNS以接收推送通知,cordova,amazon-web-services,push-notification,ionic-framework,amazon-sns,Cordova,Amazon Web Services,Push Notification,Ionic Framework,Amazon Sns,我正在使用ionic框架开发Cordova应用程序。我想使用亚马逊sns服务推送通知 我已经在应用程序中为浏览器配置了AmazonSDK。但是AWS.config.credentials.get在浏览器中执行移动应用程序时,仅返回带有数据的成功对象 但它给了安卓手机一个错误。它显示了网络连接和工作时的网络错误 createPlatformEndpoint方法也给出了凭证错误,您可以在屏幕截图中看到这两个错误。 这里还有代码快照 .run(function($cordovaPush,$rootS
AWS.config.credentials.get
在浏览器中执行移动应用程序时,仅返回带有数据的成功对象
但它给了安卓手机一个错误。它显示了网络连接和工作时的网络错误
createPlatformEndpoint方法也给出了凭证错误,您可以在屏幕截图中看到这两个错误。
这里还有代码快照
.run(function($cordovaPush,$rootScope) {
var registerForSNS = function(gcmId){
var params = {
PlatformApplicationArn: 'my amazon arn', /* required */
Token: gcmId, /* required */
CustomUserData: 'STRING_VALUE'
};
sns.createPlatformEndpoint(params, function(err, data) {
if (err)
console.log(err, err.stack); // an error occurred
else{
console.log(data.EndpointArn);
alert(data.EndpointArn);
}
});
}
AWS.config.region = 'us-east-1';
AWS.config.update({
credentials : new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'my Identity pool ID'
})
});
var sns = new AWS.SNS();
AWS.config.credentials.get(function(err) {
if (err){
console.log(err);
} else{
console.log(AWS.config.credentials);
registerForSNS();
}
});
document.addEventListener("deviceready", function(){
var androidConfig = {
"senderID": "my sender id",
};
$cordovaPush.register(androidConfig).then(function(result) {
// Success
alert(JSON.stringify(result));
}, function(err) {
// Error
alert(JSON.stringify(err));
})
$rootScope.$on('$cordovaPush:notificationReceived', function(event, notification) {
switch(notification.event) {
case 'registered':
if (notification.regid.length > 0 ) {
alert('registration ID = ' + notification.regid);
registerForSNS(notification.regid);
}
break;
case 'message':
// this is the actual push notification. its format depends on the data model from the push server
alert('message = ' + notification.message + ' msgCount = ' + notification.msgcnt);
break;
case 'error':
alert('GCM error = ' + notification.msg);
break;
default:
alert('An unknown GCM event has occurred');
break;
}
});
}, false);
});
我并没有真正的问题,为什么它不是从爱奥尼亚移动应用程序调用。但是我删除了所有的插件,然后试着让它开始工作。我知道一些插件在应用程序中添加或删除了一些与网络相关的权限