How to configure amazon SNS in Cordova mobile for receiving push notification
<p>I am developing Cordova application using ionic framework. I want to use amazon-sns service for push notification.</p>

<p>I had configure amazon sdk for browser in application. But  <code>AWS.config.credentials.get</code> only return success object with data when execute mobile application in browser,</p>

<p>But it is giving error in android mobile. It is showing network error thought network is connected and working.</p>

<p>And <code>sns.createPlatformEndpoint</code> method is also giving credential error you can see both error in screenshot.
<a href="https://i.stack.imgur.com/Oc4Cs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Oc4Cs.png" alt="enter image description here"></a></p>

<p>Here is code-snap as well</p>

<pre><code>.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 &gt; 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);
});
</code></pre>