3

I'm an iOS developer just starting to learn Android. While I've managed to figure out most of the different quirks in Android compared to iOS, I am still puzzled with the concept of push notification. I guess it's because I come from iOS background (iOS user and a developer and have never used Android before).

Unlike iOS where all I need to do is send a payload to APNS and the phone automatically displays push notifications on the lock screen, it seems like on Android that's not provided. Is this just how Android works? Is there no way to simply send a push to GCM and have it show up on lock screen automatically? I guess I'm having hard time adapting from the iOS version of what a "push notification" is to what Android considers a "push".

Vlad
  • 8,038
  • 14
  • 60
  • 92
  • It's all described in GCM documentation, have you check it already? – Szymon Dec 20 '15 at 00:58
  • Why wouldn't that be possible? If you add a `notification` object with a `title` and `message` to the push call then it will be displayed as a notification. But when would you ever want to do that? A notification like that doesn't do anything but display a title and a message. A serious app basically never does that and just handles the push message manually and creates a much richer notification. – Xaver Kapeller Dec 20 '15 at 00:59
  • I *have* read all the official documentation and probably everything I could read up on this topic, and am left with even more confusion. For example, here's a page about how to create a "Notification" https://guides.codepath.com/android/Notifications#creating-a-notification The article sounds like I have to manually create a "Notification" in order to make it show up as notification. on iOS, when you post a push notification to APNS, the device takes care of displaying notifications. I was wondering if this is not the case on Android. – Vlad Dec 20 '15 at 01:35
  • To be clear, I can see that I *am* receiving push payloads when i look at the console. what I see are key/value pairs like "gcm.notification.body: hello", "gcm.notification.title: this is a title". This is how I handle it when the app is in foreground. But when the app is in the background no "lock screen notification" shows up. – Vlad Dec 20 '15 at 01:38
  • 1
    Also another reason I'm so confused is because while the official Android document says it will automatically display push messages if I send the correct payload ({notification: {body: "body content", title: "title", icon: "icon_name"}}), there are tons of articles and SO answers saying you should manually create a Notification if you want to display them on lock screen. Example: http://stackoverflow.com/questions/12482593/android-gcm-push-notifications-not-appearing-in-notifications-list?rq=1 http://stackoverflow.com/questions/16169175/should-i-call-wakelock-before-creating-a-notification – Vlad Dec 20 '15 at 02:30

0 Answers0