-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Using this Plugin with Parse.com results in not showing Push on Android #147
Comments
Right now this plugin will not work with Parse.com see my comment here #54 (comment) I've not had a chance to revisit my fork but you could make your own. You need to modify the GCMIntentService.getString methods to also look in the "data" object. Here is my code to get the message if it helps. I also support Urban Airship.
|
@smdvdsn Great Thanks!! To be clear: I updated the function "private String getMessageText(Bundle extras)" with your code in File GCMIntentService and seems to work. Great! |
@Mojo90 it's a work around for now but I'd like to inspect the data coming from Parse so we can extract the other keys besides 'message'. |
Okay. Yep I understand. But does work for me right now because I only need to inform the users. |
But another thing: is it possible to set title in init like so?
Because Title is not shown on push notification. And I also use Local Notification Plugin there everything shows just fine. Also tried to set title via parse.com like so:
but didn't work. Title on device was just not there |
@Mojo90 To get the title on your push you just need to add similar custom code to the getString methods. If the key passed to getString == TITLE then look in the "data" object as per your modified getMessageText method. @macdonst unfortunately I've not been able to find the time to revisit this. I'm currently using the code I posted here but I don't think we should merge that in to master. I still think the best approach is to allow the keys to be configured as per my comment on #54 . I worry that we'll end up just chasing our tails trying to support every random push service out there. Thanks for all your work on this plugin. It's working great for me and if I manage to find some time I will send that PR. |
@smdvdsn mhh I tried but couldn't get it to work. so I see in console.log that in addition to alert there is the title set. what I tried in getMessageText is:
and
and
but title never shows up. Do you have one more hint how to return the title correctly? |
@Mojo90 from current master try replacing the two getString methods and the getMessageText method with this. I've not tested or compiled this but it should work. This will look for all keys in the data object that Parse sends if they are not found directly. It also adds the "alert" key to the getMessageText method.
|
@smdvdsn this is exactly why I want to take a closer look at it. Instead of modifying every getXXX() method in GCMIntentService I want to detect it is a Parse push and use the data object inside the data object in the onMessage method to be passed to createNotification. |
@smdvdsn Great! good Workaround, does for me work right now and is exactly what I need! THANK YOU! |
@macdonst I agree. I just wanted to give Mojo90 something to solve his issue. As I said I don't think this should be merged in. I think it would be good to consolidate all of this logic in the PushPlugin.convertBundleToJson method so that we don't have to duplicate the alternate keys everywhere. So in GCMIntentService.onMessage you call PushPlugin.convertBundleToJson and then pass the JSONObject around instead of the extras. convertBundleToJson should normalise all the keys to our known values "title", "message" etc Again I really think the keys need to be configurable. There are just too many different services. Urban Airship for instance doesn't use a nested object like Parse, they prefix their keys. The message is under "com.urbanairship.push.ALERT" for instance. I worry that the branching logic and list of keys to check will get out of hand. |
This change moves all alternative key logic into a single method. Also allows message keys to be in nested "data" or "message" object to support parse.com and other providers. fixes phonegap#147 replaces phonegap#218 and phonegap#182
This change moves all alternative key logic into a single method. Allows message keys to be in nested in "data" or "message" object. This is to support parse.com and other providers. Added additional keys to support Urban Airship. fixes phonegap#147 replaces phonegap#218 and phonegap#182
@smdvdsn Awesome, thanks for the PR. I'm going to look at it today. |
I think I found a bug, can someone verify this? It is related to the solution provided by this issue (I saw the issue number inside the code comments) In GCMIntentService.java Without this 'continue;', it will jump out of the if statement and run replaceKey(key, newKey, extras, newExtras);, which reverts whatever the while loop has just did.. Update: Seems like it only causes problem when the key is 'message' and it is a json object with yet another 'message' within it. |
This thread has been automatically locked. |
I am experiencing a problem with Parse.com and iOS / Android Push-Plugin.
What I am doing is: sending from parse.com a push notification to iOS and Android devices with this Backend-command:
Parse.Push.send({
where: query, // Set our Installation query
data: {
alert: message
}
}
So the type of this Notification is "alert". On iOS it is showing with no problem on Lockscreen or as Banner. But not on Android. If App is in Background I receive this on Console:
V/GCMBroadcastReceiver﹕ onReceive: com.google.android.c2dm.intent.RECEIVE
V/GCMBroadcastReceiver﹕ GCM IntentService class: com.adobe.phonegap.push.GCMIntentService
V/GCMBaseIntentService﹕ Acquiring wakelock
V/GCMBaseIntentService﹕ Intent service name: GCMIntentService-GCMIntentService-15
D/PushPlugin_GCMIntentService﹕ onMessage - context: android.app.Application@41bcf068
V/GCMBaseIntentService﹕ Releasing wakelock
(Related to this Issue: #86)
But nothing is showing up in Notification Center. As well I tried type "message" (as stated in #86) or "data" but nothing else happened. But if Android App is open I can receive type "alert" and show it via "alert(data.additionalData.data.alert)". Is this normal behavior? Because I'd like to have with the same command from my backend that the push is showing on android and ios. While I tried "message" and "data" it didn't show up on ios either. So how can I make Android showing up type "alert" in Notification Center and as Banner? Thanks!
The text was updated successfully, but these errors were encountered: