Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only Bar Notification Available - Android #13

Closed
panw opened this issue Dec 29, 2014 · 23 comments
Closed

Only Bar Notification Available - Android #13

panw opened this issue Dec 29, 2014 · 23 comments

Comments

@panw
Copy link

panw commented Dec 29, 2014

Sorry for all the posts Morten.

I am trying to enable alerts and badges, so I added the following init code to the client. However, I only get the top bar alert. This might be due to this issue I reported here.

Push.init({ gcm: { "projectNumber": 917501955460 }, alert: true, bagde: true });

Thanks for your help and the package. Happy Holidays.

@raix
Copy link
Collaborator

raix commented Dec 29, 2014

2.3.0 is out - should fix this and unify the api

@panw
Copy link
Author

panw commented Dec 30, 2014

Thanks for the update Morten.

Alerts now work when active on the app for Android phone. However, Badges does not work. When I add a listener to the client, it is never triggered:
Push.addListener('badge', function(notification) {
console.log("Badge", notification);
});

Also sound and vibrate seems to be enabled by default without having to set those options to true.

@adamgins
Copy link
Collaborator

adamgins commented Jan 9, 2015

@panthongw @raix just wondering if you got this working. I just enabled GCM, was pretty easy compared with APN (took a few mins, compared with days of APN certificate hell).

When I am not in the app and a GCM notification is received, I hear a whistle but don't get any visual

I20150109-15:19:06.137(11)? send to token { gcm: 'somelongtoken' }
I20150109-15:19:06.138(11)? sendGCM [ 'somelongtoken' ] { from: 'aginsburg',
I20150109-15:19:06.138(11)?   title: 'Some title',
I20150109-15:19:06.138(11)?   text: 'aginsburg commented on Conversation 149',
I20150109-15:19:06.138(11)?   createdAt: Fri Jan 09 2015 15:18:56 GMT+1100 (AEDT),
I20150109-15:19:06.138(11)?   createdBy: '<SERVER>',
I20150109-15:19:06.139(11)?   badge: 1,
I20150109-15:19:06.139(11)?   query: { userId: '5fa195c4721877522f5893e2' },
I20150109-15:19:06.139(11)?   _id: 'woBT5QiNmBZX5aKqX' }
I20150109-15:19:06.145(11)? Create GCM Sender using "Asomelongtoken"
I20150109-15:19:06.146(11)? A:Send message to: somelongtoken
I20150109-15:19:06.147(11)? Push: Sent message "Some title" to 1 ios apps 1 android apps
I20150109-15:19:07.437(11)? ANDROID: Result of sender: {"multicast_id":8192813545181402000,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1420777267260348%4664a0c26e2d5fd0"}]}

Note if I am in the App, I DO see an alert... it's just that I don't see an alert badge when looking at the app icon on the desktop. Not I am new to Android, so it may be a setup issue.

@raix
Copy link
Collaborator

raix commented Jan 9, 2015

try enabling badge in the config.push.json

@adamgins
Copy link
Collaborator

adamgins commented Jan 9, 2015

Thanks @raix

I put into a .Configure call (as I am getting errors with the config file)... I'll post a separate issue on that:

 Push.Configure({

        apn: {
            // setting this on client throws security error
            passphrase: 'bread50*eyes',
            // pem files are placed in the app private folder
            certData: Assets.getText('Dist_PushChatCert.pem'),
            keyData: Assets.getText('Dist_PushChatKey.pem')
        },
        "gcm": {
            "apiKey": "mykey",
            "projectNumber": mynumber
        },
        production: true, // use production server or sandbox,
         "badge": true,
         //"sound": true,
         //"alert": true,

         //"vibrate": true
    });

No luck. Still only sound.

BTW, I see the following in the console too:

I20150109-20:39:30.264(11) (android:http://meteor.local/cordova.js:1044) processMessage failed: Error: ReferenceError: error is not defined
I20150109-20:39:30.276(11) (android:http://meteor.local/cordova.js:1045) processMessage failed: Stack: ReferenceError: error is not defined
I20150109-20:39:30.276(11)? at http://meteor.local/client/views/helpers/push.js?df35e3e6f6629ff79b2fb1bb901a1fceb38fc07b:9:9
I20150109-20:39:30.277(11)? at http://meteor.local/packages/raix_eventemitter.js?2698ca3a2e678f77962ebe839ad04615958a4c26:122:16
I20150109-20:39:30.277(11)? at Array.forEach (native)
I20150109-20:39:30.277(11)? at Function._.each._.forEach (http://meteor.local/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:156:11)
I20150109-20:39:30.277(11)? at _runCallbacks (http://meteor.local/packages/raix_eventemitter.js?2698ca3a2e678f77962ebe839ad04615958a4c26:118:7)
I20150109-20:39:30.278(11)? at EventEmitter.emit (http://meteor.local/packages/raix_eventemitter.js?2698ca3a2e678f77962ebe839ad04615958a4c26:147:12)
I20150109-20:39:30.278(11)? at http://meteor.local/packages/raix_push.js?89b798f6e80bb528bcb1082c3a88a924a0c68c86:224:12
I20150109-20:39:30.278(11)? at Object.cordova.callbackFromNative (http://meteor.local/cordova.js:294:48)
I20150109-20:39:30.278(11)? at processMessage (http://meteor.local/cordova.js:1039:21)
I20150109-20:39:30.278(11)? at androidExec.processMessages (http://meteor.local/cordova.js:1076:13)

@adamgins
Copy link
Collaborator

adamgins commented Jan 9, 2015

Actually I got the config JSON things sorted out.. that was my issue.

I am getting notifications on android.. I see the "unread" (badge) in the notifications pull down but I don't see it on the app Icon like a do on iOS (perhaps this is how Android works). I am still egtting the error above... which seems related to me.. I have not looked into the raix:push code yet.

@adamgins
Copy link
Collaborator

adamgins commented Jan 9, 2015

Ah, I think I found my issue, I was calling Push.Configure in the client and it was throwing a should not be called more than once exception.

The reason I was doing this I thought I had to call it in the client once the user is logged in... ie it gets called when the app first fires up before the user logs in (but the userId will be null)... so once the user logged in I called it again.

Is this wrong? Perhaps I should move this to another thread?

@raix
Copy link
Collaborator

raix commented Jan 9, 2015

Yep you should only use the config - the package should have a computation listening on userid changes and update the appCollection... If not its a bug

@panw
Copy link
Author

panw commented Jan 10, 2015

I've tested it again and I am still not getting any bar notification when the app is open nor icon badgee when the app is closed.

I do get noise without having to set that option.

Would this is be device specific? I am testing on an HTC One running 4.1.2.

@adamgins did you have any luck getting it to work?

@raix
Copy link
Collaborator

raix commented Jan 10, 2015

There will be no bar notification when the app is open - thats expected behaviour.
You can use the startup or message events to trigger a behaviour.

The badge should update when the app is closed - not sure why its not working - did you set badge:true in the config file? (it have to be boolean true not string "true")

@panw
Copy link
Author

panw commented Jan 10, 2015

@raix in my config.push.json file I do set the badge option to a boolean true

{
  "gcm": {
    "apiKey": "xxxxxxxxxxxxxxx",
    "projectNumber": xxxxxxxxxxxx
  },
  "production": true,
  "badge": true
}

This is how I am sending a push message from the console:

Push.send({
        from: 'push',
        title: 'Hello',
        text: 'world',
        query: {} 
    });

Please let me know if something is off.

@adamgins
Copy link
Collaborator

I think I have the same issue as well. I do see notifications on the pull down menu (ie if I drag my finger down from top of screen) and the badgecount is correct... it just does not show on the App icon (like iOS)

@raix
Copy link
Collaborator

raix commented Jan 11, 2015

Does android support badge/msgCount? Im not sure

@raix
Copy link
Collaborator

raix commented Jan 11, 2015

On the app icon that is

@raix
Copy link
Collaborator

raix commented Mar 18, 2015

Is this still an issue on the latest?

@adamgins
Copy link
Collaborator

No an issue fro me anymore, not sure about @panw

@panw
Copy link
Author

panw commented Mar 20, 2015

I currently do not have an Android phone to test, so we could go ahead and close the issue and if I run into this issue in the future I'll submit a new issue.

@panw panw closed this as completed Mar 20, 2015
@raix
Copy link
Collaborator

raix commented Mar 20, 2015

Super :)

@adim86
Copy link

adim86 commented Aug 12, 2015

Hi @raix thanks for the package, It has been really useful. I am having this exact problem, did anyone find a solution to it yet? All other things are working, sound, vibrate, I am getting the notification if the app is open or closed but no badge

@bhaumikdesai91
Copy link

Hi @raix awesome API, we appreciate� your work.
I am currently trying to integrate your api in a demo project, I've managed to get the notifications correctly, but the badges count does not update on iOS device, I have read this thread thoroughly but nothing seems to work for badges, Please help me on this.. thank in advance. :)

@mitiaptest
Copy link

@raix Can you help me to work vibration and sound with notification on iOS?

@sahanDissanayake
Copy link

Yes confirmed this is still happening !! There are no badge on the icon and also if you send multiple push notifications from the server then one notification on the phone is replaced by the next notification on ANDROID

@vinnie1234
Copy link

Same problem here @sahanDissanayake. Android 6 with an Galaxy s7 Edge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants