aws-mobile-ionic-sample icon indicating copy to clipboard operation
aws-mobile-ionic-sample copied to clipboard

Not receiving push notifications outside of the app

Open barryross opened this issue 7 years ago • 6 comments

I have followed https://aws.amazon.com/blogs/mobile/push-notifications-with-ionic-and-amazon-pinpoint/ and am receiving in-app notifications when sending via "direct" in the AWS console, but when the app is in the background or closed, no notifications come through. Any ideas why?

barryross avatar Dec 22 '17 20:12 barryross

I have same problem. Any solution?

lucaslc-sp avatar Mar 22 '18 22:03 lucaslc-sp

same problem here !

Linknpay avatar Mar 31 '18 21:03 Linknpay

I also ran into this. It only appears to affect Android for me - iOS apps receive notifications while the app is in background mode no problem.

Anyone figure this out yet? Any insight would be definitely appreciated!

gthole avatar Apr 20 '18 19:04 gthole

same problem here

medbz avatar Apr 20 '18 23:04 medbz

We had the same problem and we solve it for android background mode. Solution:

  1. Do not use FCM, use GCM. So, install the ionic push plugin v1 not v2.
  2. Do not use "withBody" function when sending messages to Android, use "withRawContent" instead with a json object as showed in the java example below:
JSONObject gcmMessage = new JSONObject();
      try {
          JSONObject data = new JSONObject();
          data.put("title", title);
          data.put("body", message);
          gcmMessage.put("data", data);
      } catch(JSONException e){
          LOGGER.error(e);
      }

      DirectMessageConfiguration directMessageConfiguration = new DirectMessageConfiguration()
              .withAPNSMessage(new APNSMessage().withTitle(title).withBody(message).withSound("default"))
              .withGCMMessage(new GCMMessage()
                      .withRawContent(gcmMessage.toString())
                      .withSound("default"));

Hope it helps !

Linknpay avatar Apr 21 '18 00:04 Linknpay

Well hooray! That worked very nicely. Thanks so much!

I'm a bit distressed that this only buys us a year before GCM is phased out and FCM is the defacto push notification API, but I'll take it for now.

Thanks again for the magic spell.

gthole avatar Apr 26 '18 15:04 gthole