I have been playing with Google C2DM, and managed to successfully get the push working. When I was trying to understand the code,
The C2DMReceiver class of Google C2DM, has a constructor in it, which has the following lines
public C2DMReceiver() {
// Email address currently not used by the C2DM Messaging framework
super("dummy#google.com");
}
My question is, what does this email denote? Is it the same if I remove the super statement?
Any help would be appreciated.
Thanks
Nithin
The reason for that is because Google uses that email address only as a reporting mechanism and doesn't really use it for anything else. So for now you can just supply anything and it will still work but it is advised to use the email address you used to register for the push notification services.
Related
I try about week to send notification between devices using Firebase Functions now i found delay or the notification don't received to another device so after many trys i found solution is iam generate wrong token so i seek now the right way to generate tokens
FirebaseInstanceId.getInstance().getToken()
its return wrong token
extends FirebaseMessagingService
cant know how it works and after many tries it still return null
How do i get the device token when a user is registered in an app.The purpose is that i want to send push notification using fcm. Can anybody please help ?
When I did kinda the same thing I went with this lib: https://github.com/evollu/react-native-fcm
Which I think works great btw.
When the user clicks on the register button or whatever, I do:
FCM.getFCMToken().then(token => {
//Send register request
});
The token can change as well, so whenever the app is started I compare the existing key from AsyncStorage and if it has changed I'll use the same procedure to update the key backend.
Hope this helps, good luck.
I am trying to get the access token for Baidu Push Notification. I've done everything according to their SDK documentation and I am able to send push notifications from their console. I went through their documentation and I am using this line of code to start the service.
PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_API_KEY, Utils.getMetaValue(SplashActivity.this, "api_key"));
there is another method that uses
PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_ACCESS_TOKEN, Utils.getMetaValue(SplashActivity.this, "api_key"));
but I can't seem to get it to work or get the access token, probably due to a mistake in the code I am using. Could anyone guide me? I am able to get things like userId, channelId and requestId when I use the first method though, would one of these be the access token instead?
When I use the second method I get a "30603 Illegal construction request, server-side validation failed" error.
All of the guides are in Mandarin and Google Translate could only go so far. Help would be much appreciated.
You can find your resultCode like this.
your resultCode
code error list
I try to use Google oauth to authenticate users on my android app.
Then I would like to send it to my app server so it can connect at any time with Google calendar.
I tried to use
GoogleAuthUtil.getToken(getApplicationContext(), mAccountName, mScope);
Following this article:
https://developers.google.com/accounts/docs/CrossClientAuth
When I use it with scope
mScope = "oauth2:https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile";
I get a token, which is valid for an hour
But when I try to get an authorization code (so I can get a refresh token that is valid for longer time, using
mScope2 ="oauth2:server:client_id:{CLIENT_ID}.apps.googleusercontent.com"+ ":api_scope:https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile";
I receive either "invalid_scope" or "Unknown" exceptions.
What am I doing wrong?
EDIT:
OK, After creating a new app on google API console and adding plus.login to the scope I get a code, but for some reason my server can't resolve this token. When tying to resolve server gets an error about the redirection URL.
BTW, When I do the web flow with same parameters it works.
OK, found the solution, I expected Google to have a lot better documentation about working with Google Oauth and Android. A few things you have to know to work with Android and offline token
When you create google Client ID Don't create a service application before you create a web application
Must include https://www.googleapis.com/auth/plus.login in your scope
The weirdest, to resolve the one time authorization code on my server, I had to use the redirection URL from the Android client ID details (which doesn't even look like a url) and not from the Web client details on Google API console.
That scope string is only documented to work when passed to GoogleAuthUtil(), see http://developer.android.com/reference/com/google/android/gms/auth/GoogleAuthUtil.html, on Android. But it would be cool if it worked on iOS too; our infrastructure there is a little behind where we’re at on Android.
I have had the same issue then i realised that my app is not published and is in debug mode, so i had to add test users to the Google project -> Consent Screen, then i was able to fetch the token for the added test user.
You just need to follow the correct steps/format for specifying the scopes. Find them here https://developers.google.com/android/guides/http-auth#SpecifyingScopes
I am Trying to fetch and push A notification (To inform the device to connect to the data source because it has been changed/Updated)
I read A lot of tutorials about it , and tried to apply it to help me in my case , but really i faced some problem understanding the GCM HOW IT Works
I've register at https://code.google.com/apis/console and take the SENDER ID AND APIKEY
Now I've Some Questions :
do you register the device to the service every time we start the application or only for the first time ?
do we use GCM for (only notify the device something happens) or to (notify and get the information about whats is changes) ?
why this operation need (Client And Server)
I mean (Client) it's OK Because he'll receive the push notification ,, but (Server What it Means Here) :( ,, because i think the server here will be the Google it self to notify the device
In this Case When We Use A APIKEY
the Idea Is :
I've SQL Server Database on my web-site and have small android application (Dealing With it) with two users
need when any user Add A record to the database notify the other user
Thanks In Advance ,,
Regards :)
1) You register with GCM only when you need to. E.g. When you call
GCMRegistrar.getRegistrationId(appContext);
And it returns a blank string. Typically this happens the first time you launch your app.
2) It depends on what the data you are trying to is and whether or not it will fit within the 4K payload limit. Take a look at the Send-to-Sync vs. Messages with Payload Google Help topic.
3) Your server is the server that sends the message to the GCM servers. The GCM servers then send the message down to the apps. Take a look at this blog post I wrote for a service that I helped create: http://blog.andromo.com/2012/how-does-airbop-push-messaging-work/ It should help explain how this works. In the explanation you can just substitute our servers with your own.
4) You send your API key as part of your message to the GCM servers as detailed here: http://developer.android.com/google/gcm/gcm.html#request
So in the following request:
Content-Type:application/json
Authorization:key=AIzaSyB-1uEai2WiUapxCs2Q0GZYzPu7Udno5aA
{
"registration_ids" : ["APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx..."],
"data" : {
...
},
}
Authorization: key=YOUR_API_KEY