Appery PushPlugin and how to manage onNotification events

This forum contains topics that were moved from Get Satisfaction
Fernando
Posts: 0
Joined: Sat Mar 14, 2015 10:59 am

Appery PushPlugin and how to manage onNotification events

Post by Fernando »

I'm working in a proyect with appery as frontend and Azure Mobile Services as backend.
I want to deploy a support chat inside the app using notifications as chat responses (if it's correct, i'm learning about this).

First, I don't know if appery has pushplugin or if a need to add it manually (and how to do it...). Second, i need to make it works and then i don't know how to manage onNotification events in Android and iOS inside appery.

I've read this post, but i need help.
https://getsatisfaction.com/apperyio/...

Thank you and sorry for my english,
Best regards.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Appery PushPlugin and how to manage onNotification events

Post by Evgene Karachevtsev »

Hello Fernando,

Appery.io has built-in push notification: https://devcenter.appery.io/tutorials...
And it has push notification event: http://screencast.com/t/cvcYCv6K

Fernando
Posts: 0
Joined: Sat Mar 14, 2015 10:59 am

Appery PushPlugin and how to manage onNotification events

Post by Fernando »

How can i access the content message from notifications and redirect to different pages?

I've created a javacript alert at push notification in the main page of my app and it shows me the alert when i receive notifications, but i also tried to create javascript code to manage notifications at device ready event and after that i can't see the notification alert from the javasctipt push notification event

I paste the code from https://github.com/phonegap-build/Pus... and edit to show me alerts:

alert("custom device ready event");

var pushNotification;
pushNotification = window.plugins.pushNotification;

if ( device.platform == 'android' || device.platform == 'Android'){
pushNotification.register(
successHandler,
errorHandler,
{
"senderID":"senderID",
"ecb":"onNotification"
});
}

// result contains any message sent from the plugin call
function successHandler (result) {
alert('result = ' + result);
}

// result contains any error description text returned from the plugin call
function errorHandler (error) {
alert('error = ' + error);
}

//ecb (Amazon Fire OS, Android and iOS)
//Event callback that gets called when your device receives a notification

// Android and Amazon Fire OS
function onNotification(e) {
//$("#app-status-ul").append('EVENT - RECEIVED:' + e.event + '');

Code: Select all

 switch( e.event ) { 
  case 'registered': 
      if ( e.regid.length  0 ){ 
          alert('REGISTERED - REGID:' + e.regid); 
      } 
  break; 

  case 'message': 
     // if this flag is set, this notification happened while we were in the foreground. 
     // you might want to play a sound to get the user's attention, throw up a dialog, etc. 
      if ( e.foreground ) 
      { 
          alert('--INLINE NOTIFICATION--'); 

          // on Android soundname is outside the payload. 
          // On Amazon FireOS all custom attributes are contained within payload 
          var soundfile = e.soundname || e.payload.sound; 
          // if the notification contains a soundname, play it. 
          var my_media = new Media("/android_asset/www/"+ soundfile); 
          my_media.play(); 
      } 
      else 
      {  // otherwise we were launched because the user touched a notification in the notification tray. 

          if ( e.coldstart ) 
          { 
              alert('--COLDSTART NOTIFICATION--'); 
          } 
          else 
          { 
              alert('--BACKGROUND NOTIFICATION--'); 
          } 
      } // else 

  break; //case message 

  case 'error': 
      alert('ERROR - MSG:' + e.msg); 
  break; 

  default: 
alert('EVENT Unknown: an event was received and we do not know what it is'); 
  break; 

} // switch (e.event)
} // function errorHandler

Thank you very much.

Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

Appery PushPlugin and how to manage onNotification events

Post by Serhii Kulibaba »

You can read push message on the "push nofification" event. It is available in variable codedata.aps.alert/code

Fernando
Posts: 0
Joined: Sat Mar 14, 2015 10:59 am

Appery PushPlugin and how to manage onNotification events

Post by Fernando »

Ok, that is!

I have some questions:

1) Can i send a notification with a title in notification tray as "You have support response" and then process the content of the notification message? Or i need to store responses in a database and only send the notification with that title?

2) How can i hide notification from notification tray when the app is open and process the notification without disturbing the user?

3) I am also trying to send notifications from Azure notification hub but it sends me blank notification without message. I don't know if there is some problem whith push plugin. Can you tell me something about this?

Thank you very much.
Best regards.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Appery PushPlugin and how to manage onNotification events

Post by Yurii Orishchuk »

Hi Fernando,

1 No, you can not send message inside push notification.
Push only uses to notify user about some event. Then user open app and app get update from remote server about this update.

2 Unfortunatly you can not do it with built-in functionality.

3 Please add us more details (screen shots) about this problem.

Regards.

Fernando
Posts: 0
Joined: Sat Mar 14, 2015 10:59 am

Appery PushPlugin and how to manage onNotification events

Post by Fernando »

Hi again!

About manage notifications when the app is open, i've read something about PushNotification.getPendingNotifications(). Can it help me?

I've fixed the problem with Azure notification, changing in the GCM payload "message" to "alert".

Thank you.
Regards.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Appery PushPlugin and how to manage onNotification events

Post by Evgene Karachevtsev »

Hello Fernando,

Looks like that it is the plugin: https://github.com/Pushwoosh/phonegap...
And unfortunately plugins are outside the scope of our support.

Post Reply