NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

.service('PushNotificationsService', function ($rootScope, $cordovaPush, NodePushServer, GCM_SENDER_ID){
/* Apple recommends you register your application for push notifications on the device every time it’s run since tokens can change. The documentation says: ‘By requesting the device token and passing it to the provider every time your application launches, you help to ensure that the provider has the current token for the device. If a user restores a backup to a device other than the one that the backup was created for (for example, the user migrates data to a new device), he or she must launch the application at least once for it to receive notifications again. If the user restores backup data to a new device or reinstalls the operating system, the device token changes. Moreover, never cache a device token and give that to your provider; always get the token from the system whenever you need it.’ */
this.register = function() {
var config = {};

// ANDROID PUSH NOTIFICATIONS
if(ionic.Platform.isAndroid())
{
config = {
"senderID": GCM_SENDER_ID
};

$cordovaPush.register(config).then(function(result) {
// Success
console.log("$cordovaPush.register Success");
console.log(result);
}, function(err) {
// Error
console.log("$cordovaPush.register Error");
console.log(err);
});

$rootScope.$on('$cordovaPush:notificationReceived', function(event, notification) {
console.log(JSON.stringify([notification]));
switch(notification.event)
{
case 'registered':
if (notification.regid.length > 0 ) {
console.log('registration ID = ' + notification.regid);
NodePushServer.storeDeviceToken("android", notification.regid);
}
break;

case 'message':
if(notification.foreground == "1")
{
console.log("Notification received when app was opened (foreground = true)");
}
else
{
if(notification.coldstart == "1")
{
console.log("Notification received when app was closed (not even in background, foreground = false, coldstart = true)");
}
else
{
console.log("Notification received when app was in background (started but not focused, foreground = false, coldstart = false)");
}
}

// this is the actual push notification. its format depends on the data model from the push server
switch(parseInt(notification.message)){
case 2:
alert('WoW, Your order has been assigned to a delivery man');
break;

case 3:
alert('Your order is being packed now !');
break;

case 4:
alert('Your order has been delivered');
break;
}
break;

case 'error':
console.log('GCM error = ' + notification.msg);
break;

default:
console.log('An unknown GCM event has occurred');
break;
}
});

// WARNING: dangerous to unregister (results in loss of tokenID)
// $cordovaPush.unregister(options).then(function(result) {
// // Success!
// }, function(err) {
// // Error
// });
}

if(ionic.Platform.isIOS())
{
config = {
"badge": true,
"sound": true,
"alert": true
};

$cordovaPush.register(config).then(function(result) {
// Success -- send deviceToken to server, and store for future use
console.log("result: " + result);
NodePushServer.storeDeviceToken("ios", result);
}, function(err) {
console.log("Registration error: " + err);
});

$rootScope.$on('$cordovaPush:notificationReceived', function(event, notification) {
console.log(notification.alert, "Push Notification Received");
});
}
};
})
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.