I'm trying to create a Xamarin android app with GCM push notifications using this plugin:
https://github.com/rdelrosario/xamarin-plugins/tree/master/PushNotification
I followed the instructions in the readme page and changed ANDROID SENDER ID with my google project number (obtained from the google developer console).
I can successfully register the device using the Register function (the OnRegisteredfunction on the CrossPushNotificationListener class is fired and a valid registration token is returned).
To send a notification I used this tool (because i don't have a backend up and running):
http://apns-gcm.bryantan.info/
I filled:
The Device Token field either with the token obtained with the
previous device registration or with "/topics/global"
The Message field with a random message
The Api Key with a Server API Key generated from the google
developer console
The app never reaches the OnMessage and nothing seems to be received.
What am I doing wrong?
Thanks in advance
Related
I am trying to build a wrapper app with cordova and using PHP as server backend.
I am using cordova-plugin-fcm to handle push notification.
Correct me if I am wrong, each device (android and ios) has own id which is used to send notification.
How can I get that id and send it to PHP route so that I can bind it with the logged in user and send notification?
//FCMPlugin.onTokenRefresh( onTokenRefreshCallback(token) );
//Note that this callback will be fired everytime a new token is generated, including the first time.
FCMPlugin.onTokenRefresh(function(token){
alert( token );
});
In above example token is the id to be send to PHP to send notification?
Can the device.uuid used for sending notification?
I have already setup my Firebase configuration and the project has google-services.json and GoogleService-Info.plist in place.
Thank you
Firebase Cloud Messaging targets its messages at a specific app on a specific device. Each specific app install is identified by Firebase's Instance ID, also referred to as a device registration token, or an FCM token.
The Firebase documentation on accessing the registration token says this about it:
On initial startup of your app, the FCM SDK generates a registration token for the client app instance. If you want to target single devices or create device groups, you'll need to access this token by extending FirebaseMessagingService and overriding onNewToken.
From a quick read through the Cordova documentation on device.uuid, this seems to merely identify the device, and not the app on the device. Since FCM messages are delivered to a specific app on each device, it seems unlikely you can use the UUID of the device as a replacement.
Even if the UUID is unique for each app on each device, it won't be a drop-in replacement, as FCM only works with its own registration tokens. At the very least you'll need to keep a mapping of the device.uuid values to their corresponding FCM token.
Am setting up push notifications for my Android App. The App is not published into Google Play Store yet. Am testing this app by installing APK directly on my mobile.
Can FCM (Firebase Cloud Messaging Server) send notifications to mobile phones which has done installation from APK files directly (not through playstore)?
Just want to know how FCM will work in this case?
YES. FCM can send notifications to your app as long as your device is registered to receive messages with FCM server
On initial startup of your app, the FCM SDK generates a registration token for the client app instance. FCM Server will manage the registration token and use this token to identify your device and send notifications. Note that the registration token can be changed in some case View more here
You can test by sending notifications to your device from Notification Composer. Select target is Single Device and your registration token is target device.
// Get the current registration token
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
To handle message follow the document
Yes you can do by using Firebase console
In firebase console select Function tab which is present in left part of firebase console.
Download node.js in your system and code it according to your wish in node.js.
Firebase token should be mention in your java code.
I am building an push notification service using https://github.com/geeknam/python-gcm
this requires an API_KEY and Registation ID of device to send message.
I have created an app on console.developers.google.com and have got the API_KEY.
Now i have no clue how to get the Registration ID.
Are there dummy app(s) on installation of which it will return registration ID or something like that ?
I have created an app on console.developers.google.com and have got the API_KEY.
You'll only be able to get a valid Server Key when you create a project in Firebase Console. API Keys (recently) generated in the Developer's Console would not work for GCM (and FCM). From the note in the docs (under Server Key):
Starting from September 2016, you can create new server keys only in the Firebase Console using the Cloud Messaging tab of the Settings panel. Existing projects that need to create a new server key can be imported in the Firebase console without affecting their existing configuration.
Are there dummy app(s) on installation of which it will return registration ID or something like that?
You'll have to create your own dummy app where you'll have to call the getToken() to generate a Registration token (aka Registration ID). See the FCM Quickstart in GitHub.
We are developing apps both in IOS and Android. GCM push notification has been enabled for IOS and its working fine now. The package name for both the platforms are going to be the same.
I was given SERVER API KEY and SENDER ID by ios developer to set up gcm for android. While looking for the steps, I came across https://developers.google.com/cloud-messaging/android/client.
I kept to myself that the steps listed in the contents need to be done to set up GCM for android (please correct me if I am wrong).
Get Config file and add it to Android project
Set up Google play services (I added gcm in my project dependency)
Add entries to Manifest file
Check for google play services APK
Obtain registration token.
"An Android application needs to register with GCM connection servers before it can receive messages"
"The client app should store a boolean value indicating whether the registration token has been sent to the server." - My backend team told me I dont need to send them anything I have to just configure gcm in the app and the app will receive messages from backend.
So, My question is Do I need to have RegistrationIntentService and MyInstanceIDListenerService. Also, Do I have to define my InstanceIDListenerService in Manifest?
Our backend uses device id to send push notifications to devices so they dont need registration token to be sent to them as we send device id. So in this case, Should I register my app with GCM using RegistrationIntentService and InstanceIDListenerService? if so, should the app keep the registration token with itself. Is this registration needed?
GCM supports three types of downstream (server-to-client) messaging: send to a specific device (also called "simple" or "targeted"), send to a topic, or send to a device group. Your question says, "our backend uses device id to send push notifications to devices". It is not clear what "device ID" is and which type of messaging you intend to use. Your backend team has told you that you "don't need to send them anything". If that is true, I don't know where they are getting the "device ID".
Each of the three types of messaging provided by GCM require client devices to register with GCM and obtain a registration token. To send a message to a specific device, the registration token is effectively the "device ID". So yes, you need to implement something similar to the RegistrationIntentService and InstanceIDListenerService described in the documentation.
The description in the documentation about needing to send the registration token to the App Server is misleading. That is only required for targeted messaging. The documentation for receiving topic messages states: "Note that, for topic messaging it's not required to send the registration token to your app server; however, if you do send it, your server can verify the validity of the token and get more information about the app that created it."
When using the API key generated for my project from Google developer console in the server side to send GCM - Push notifications, i am getting a 'MismatchSenderId' error. I have cross checked the sender ID in my application and the API key also, which is correct.
Also when creating an API key for push notification implementation, should i go for 'Server key' or 'Browser key' or 'Android key' .I have maps implementation also in my project.
I am new to push notification implementation, so kindly excuse if question is too broad.
when creating an API key for push notification implementation, use:
Server Key to send from your server
Browser Key to send from a web app
Android Key to send from an android app.
also the Sender Id, is really the project id.