Skip to content

Instantly share code, notes, and snippets.

@LuisRodriguezLD
Created January 20, 2017 20:27
Show Gist options
  • Save LuisRodriguezLD/0257300f08eae90e97d81682148c8b22 to your computer and use it in GitHub Desktop.
Save LuisRodriguezLD/0257300f08eae90e97d81682148c8b22 to your computer and use it in GitHub Desktop.
function APNStoFCM(token) {
var body = {
application : 'com.your.app',
sandbox : true,
apns_tokens : [
token
]
};
var options = {
method: "POST",
headers: {
'Accept': 'application/json',
"Content-type": "application/json; charset=UTF-8",
'Authorization' : 'key=your_key'
},
body: JSON.stringify(body)
}
fetch("https://iid.googleapis.com/iid/v1:batchImport", options)
.then(function(response) {
return response.json();
}).then(function(response) {
console.log("Prueba " + JSON.stringify(response))
}).catch(function(error) {
console.log("Error " + JSON.stringify(error))
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment