use GCM to talk between iOS and Android - android

So I'm on a team working on a cross-platform app using GCM.
The Android and iOS Team each has it's own GCM Sender ID and Server API Key.
Each platform can register and get a token.
Each platform can successfully use GCM to talk to matching hardware : iOS -> iOS and Android -> Android...
The problem is we can't talk cross platform iOS -> Android and vice versa!?!? I get a "MismatchSenderId"...
What am I missing?
I've tried using the Android Sender ID to register on iOS and that won't let me register...
So I'm at a loss as to how I'm suppose to use GCM to talk from iOS -> Android?
Any Help??

SenderID in GCM by definition (here):
A unique numerical value created when you configure your API project
(given as "Project Number" in the Google Developers Console). The
sender ID is used in the registration process to identify an app
server that is permitted to send messages to the client app.
You can spot it in Developer Console at the top left corner besides the options list (API & Auth etc...)
This error is thrown because this SenderID does not match with the API key for the project. Meaning you are probably using the API key from another project and using another project number (SenderID). Please check that you are using the right values at right places.
About implementing GCM for cross-platform communication is fairly simple since it is now available to iOS by API. If that's not working out for you there are third party libraries to help with it as well.
Useful resources:
GCM iOS implementation
Cordova Plugin for PushNotification

Related

MobileFirst 7.1.0 Android FCM Push Notifications

We have developed a hybrid application using MobileFirst 7.1.0 and are looking to implement push notifications. With the recent changes regarding GCM to FCM, I'm wondering if it would be possible to add the project to FCM and use the API Key and Sender ID? I have seen the documentation has been updated for MobileFirst 8.0 and wondering if the same will work on 7.1.0.
The documentation has indeed did not yet get updated for 7.1, but it is the same as for 8.0 (the part of registering the project in FCM Console and obtaining the key and senderId), so you can follow the same instructions.
Visit the Firebase Console.
Create a new project and provide a project name.
Click on the Settings “cog wheel” icon and select Project settings.
Click the Cloud Messaging tab to generate a Server API Key and a Sender ID and click Save.

Sending message from web browser plugin to android and IOS application using XMPP

I am developing an application that needs to send message from my web browser plugin to my android or IOS app client and get response back on the plugin.
I found XMPP as an option for that but it requires separate jabberID(JID) for each client. But I need to use the same ID lets say users Gmail ID on both the plugin and the mobile application.
Is there any work around so that same Id can be used in the plugin and mobile app or if there is a better way to do this.
You should take a look at Google Cloud Messaging. The underlying protocol is actually XMPP, and it can efficiently push messages between your server (or client!) and Chrome, Android and iOS.
It also comes with powerful features like Device Groups, which let you send a single push message to Google and have it pushed out to numerous devices at once.
For your specific use case, check out the Chrome and Android docs for GCM.

Android Messages - Development vs Distribution

Forgive me for not knowing the correct Android termonology. I come from an iOS background so I'm trying to learn how to do two things correctly in the Android world.
Control "Badges" for Android
Send "Push Notifications" via Distribution (production) vs Development.
Fortunately I found the answer to #1 which is to use Status Bar Notifications thanks to this question.
Now for #2. I already have a GCM setup and can send notifications out to all registered devices. However, sometimes I want to be able to send notifications to all user's phones, and sometimes only to "development" devices. With iOS this is distinguished by devices that have been downloaded from the App Store / Ad-Hoc environment (Distribution) and devices that have been physically plugged into a computer which complies the source onto their device (Development). Is there anything similar to this for Android?
There is no difference between development and distribution in Google Cloud Messaging. All the messages are sent from your server to the same GCM endpoint.
If you want to distinguish between development devices and non-development devices, you'll have to manage it on your server's DB (for each registration ID you store in your server, add a flag that says if it's a development device or not).
EDIT :
Actually there's something else you can do, though I'm not sure it's such a good idea. When the app registers to GCM, it supplies a sender ID (which is a Google API project ID). You can use two different project IDs for development release and production release. The registration IDs returned by the registration process are tied to the project ID. Now, when you send a GCM message from your server, you send it using an API key that is tied to a project ID. If you use the API key that is tied to your development project ID, only registration IDs which are tied to that project ID (i.e. they originated from devices that have the development build) will work. Sending messages with "production" registration IDs will result in MismatchSenderId error (which is similar to APNS in the way that sandbox device tokens are invalid in the production environment and vice versa). I'm not sure that's a good idea, because you don't want to rely on errors from Google for your logic. If you want to send messages only to a subset of your clients, you should manage this subset in your DB.

Create push notification in android

how to create push notification in Android using GCM or either C2DM i have tried and check some sites and didn't get exact answer.i need to know how it works.Can any one provide me good tutorial on push notification
Could anybody help me. Thanks!!
Its Depend on your requirement what you have to do.
here is sample of C2DM: in this sample android device is registered wtih server after that server send massage to all device. so there is one way communication(server to Android device)
So all things are done at server side. just download this tutorial. Both Server side(PHP) and Android code are available.
Edited:
you got application key from Google services which you have to put at server side.
SENDER_ID – Google project id which you have to send when you want to register your device with server.
You can use GCM demo app supported by Google. One needs to install GCM libs using SDK manager and then create API keys in Google APIs console. Follow instructions from the link and you can create an app that receives push notifications from GCM server. I did try this and it worked even on my Android emulators. You need to use Emulator that targets Google APIs though.

GCM for sending notifications on android mobile app from Salesforce

We are trying to send the notification to an Android App about any event generated in salesfoece(Like creating an account), using the Google's GCM(Google Cloud Messaging).
Here is the link that tell about the GCM ,
http://developer.android.com/guide/google/gcm/gs.html#android-app
I m using Eclipse for creating Android App and my GCM server gave me the SenderID and API key.
But the problem is , How can I use Salesforce as my 3rd Party Application,from where the notifications are generated.
Starting with the Spring 14 release, Salesforce supports Google ( GCM ) and Apple ( APNS ) mobile push notifications via the Connected Apps framework. Please check the Mobile Push Notifications Tip Sheet on Developer Force for more information: http://www2.developerforce.com/en/mobile/resources
You will likely need to monitor the API for events from salesforce by polling; otherwise you might be able to get events sent to a specific URL. I'm not positive that you can specifically send a push notification from salesforce itself.
However, with your application you should be able to build in some middleware to handle that.

Categories

Resources