raix-push icon indicating copy to clipboard operation
raix-push copied to clipboard

FCM - Android - Firebase Cloud Messaging

Open Wade-BuildOtto opened this issue 8 years ago • 15 comments

It looks like GCM is being depreciated, and FCM is now the new standard, I wouldnt expect GCM to be round for that much longer they will eventually make it so you can get GCM and then they will turn it off completely.

Wade-BuildOtto avatar Jun 22 '16 20:06 Wade-BuildOtto

In services and api's for my app, I don't see GCM as something I can manage, only FCM.

Neobii avatar Jul 06 '16 15:07 Neobii

under API Manager > Mobile API's > Google Cloud Messaging

its their for now but I don't know for how long.

On Wed, Jul 6, 2016 at 9:23 AM, Adam [email protected] wrote:

In services and api's for my app, I don't see GCM as something I can manage, only FCM.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/raix/push/issues/226#issuecomment-230806437, or mute the thread https://github.com/notifications/unsubscribe/APG2rzeY1ROqBtkF_2tmkeQJTOL0cKAiks5qS8h1gaJpZM4I8Kn9 .

Wade-BuildOtto avatar Jul 06 '16 16:07 Wade-BuildOtto

We should start adopting FCM when supported in the cordova (https://github.com/phonegap/phonegap-plugin-push/issues/929) - it seems like the server-side npm packages are already there (https://www.npmjs.com/search?q=FCM)

raix avatar Jul 13 '16 15:07 raix

I couldn't get a GCM server key to work so I grabbed an FCM server key and used it in the "android" apiKey and projectNumber/senderID fields. So far it properly generates Android push messages (Meteor 1.4.1.1, raix:[email protected], raix:[email protected], raix:[email protected]). I thought I'd volunteer this info in case it helps prioritize your work load. Thanks so much for this package!

totoide avatar Sep 21 '16 23:09 totoide

Thanks @totoide thats good news - we should update the Android documentation then,

raix avatar Sep 22 '16 04:09 raix

@raix I made some quick updates to the documentation and I think I properly created a pull request #251 .

totoide avatar Sep 22 '16 17:09 totoide

At this moment, is possible to use FCM with the plugin on both platforms( Android, IOS )?

MateusAndrade avatar Sep 26 '16 13:09 MateusAndrade

At this moment, is possible to use FCM with the plugin on both platforms( Android, IOS )?

I would like to know this also..

VilleImmonen avatar Jan 13 '17 12:01 VilleImmonen

I just tested FCM and it works with Android. I actually just came here to say that if you test your notification, you have to have your app closed otherwise the notification won't show! On Android at least. This cost me many hours to find out 😆

bergjs avatar Mar 30 '17 17:03 bergjs

Right - so if you want to show a notification while the application is open you have to handle it yourself eg. via the native local notifications api. (showing the native notification while the app is open is not the common behaviour, could result in bad UX)

Relevant events are described in the "advanced.md" (hint "startup"/"message")

raix avatar Mar 30 '17 18:03 raix

Here's what's in my code that's related to the push notifications.

In main.js (server)

Meteor.startup(() => {
  ...
  Push.Configure({
    gcm: {
      apiKey: 'verylongkey', // from https://console.firebase.google.com/project/<project_id>/settings/cloudmessaging
    }
  });
...
}

In main.js (client)

Meteor.startup(() => {
  Push.Configure({
    android: {
      senderID: 1234, //number, not a string. From same url as above
      alert: true,
      ...
    },
    ...
  });

 ...
});

In the method

Push.send({
  from: '...',
  title: '...',
  text: `...`,
  query: {
    userId: data._id
  }
});

Other things I can think of:

  • is the app closed when sending the notification? This was my mistake, see above
  • maybe you have to build the production app and install it?
  • you can send test notifications directly from Firebase to test if the client part is working: https://console.firebase.google.com/project/<project_id>/notification/compose

bergjs avatar Apr 18 '17 20:04 bergjs

I deleted my .meteor folder and rebuilt and it worked fine. Thanks though! I tried deleting my comment but you responded before I could :)

On Apr 18, 2017 3:28 PM, "Jonas Bergert" [email protected] wrote:

Here's what's in my code that's related to the push notifications.

In main.js (server)

Meteor.startup(() => { ... Push.Configure({ gcm: { apiKey: 'verylongkey', // from https://console.firebase.google.com/project/<project_id>/settings/cloudmessaging } });... }

In main.js (client)

Meteor.startup(() => { Push.Configure({ android: { senderID: 1234, //number, not a string. From same url as above alert: true, ... }, ... });

... });

In the method

Push.send({ from: '...', title: '...', text: ..., query: { userId: data._id } });

Other things I can think of:

  • is the app closed when sending the notification? This was my mistake, see above
  • maybe you have to build the production app and install it?
  • you can send test notifications directly from Firebase to test if the client part is working: https://console.firebase. google.com/project/<project_id>/notification/compose

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/raix/push/issues/226#issuecomment-294971052, or mute the thread https://github.com/notifications/unsubscribe-auth/AOG_BNUx6GdAy-Y786GkEWdfw9moYO6Hks5rxRzRgaJpZM4I8Kn9 .

ChrisKG32 avatar Apr 18 '17 20:04 ChrisKG32

Well, now it's out there to help others 😄

bergjs avatar Apr 18 '17 20:04 bergjs

Hi, Did you guys try to use topics notifications ?

Hi @raix and everybody. I do not speak English well, hoping people will understand. How to send FCM messages without running the client? Thanks!

haileebn avatar Feb 01 '18 08:02 haileebn