I'm using this plugin (https://github.com/phonegap-build/PushPlugin) to send notifications to my users using my android app. Well, so far it's ok.
I have the following questions:
Every time the user opens my app I need to generate a new "RegID"? Or,is not necessary?
Because I'm saving the "RegID" in the database, for later make a shipping notification with PHP to the user's device.
What if every time open the app necessary generate a new "RegID" need to update my database alright?
Somebody can help?
No, you don't have to generate a new Registration ID in each launch of your app. You should only generate it the first time your app is launched (and it's also recommended by Google to generate it again when a new version of your app is installed).
Even when you request Google for a new Registration ID, you might get in response the same registration ID you already had, in which case make sure you don't duplicate that Registration ID in your DB.
Related
I shifted from parse.com to oneSignal for push notification service.
I integrated the SDK into my android app and it is able to create a user record in oneSignal, when the application is installed.
But when I uninstall and re-install my android app, a new user record is created in oneSignal, resulting in duplicate user records.
How do I over come this issue of duplication? I want only one user record even if the user reinstalls my application.
In parse.com I use to check at the parse cloud code for duplicates before inserting new records .. any thing similar at oneSignal ?
OneSignal's SDK does its best to try to prevent duplicate user records from being created. This is mainly done by checking the users' Advertising Identifier, basically a unique ID that remains the same between different times the application is installed.
However, some Android users have opted-out of allowing apps to see their Advertising ID. In these cases it is not possible for OneSignal to know that a user has re-installed the app, and a duplicate user record will be created.
When OneSignal next attempts to send a notification to the previous user record, Google's GCM servers notify OneSignal's system that the user has a newer push token. At this point OneSignal will then disable the old user record so that future notifications are not sent to it. OneSignal's SDK will also make sure not to ever display the same notification twice on a device.
you have to do it this way before you create a new user check if the the user is already present using this api idsAvailable in android
https://documentation.onesignal.com/docs/android-native-sdk
and the same one for server can be found here
https://documentation.onesignal.com/reference
hope you all fine
My problem is somecompany made an application for me for android and ios
and now I want to transfer these apps to my accounts
the problem is these accounts have GCM. so I want to keep these IDs
they told me that they will give me the GCM IDs database
and I have to make a script to handle the send of notification
But I know that when you register a new device with gcm you have to pass the
project ID.. that you made on your google account
and I have a different project ID than they have.
so the register of any device will vary ..
the new devices will work without any problem
but my problem is with the old devices!!
when I send a notification with the Device ID and the access token
the token is for another project ID that this Device ID generated to !!
so I think it will fail and not send any notification for old clients ..
its true ???
if its true please may you give me the correct way to transfer the app with GCM project or clients
thank you.
Different behaviors on iOS and Android
We have been trying to implement GCM on Android and iOS but there is a discrepancy on behaviors with the instanceID.
On Android and iOS when we request an instance ID every time we register our app we get the same token, this is true if we do not uninstall and install the app again, if we do that, we have a new instance ID on both, but the old android token becomes NOT_REGISTER and the old one on iOS is still working, leaving us to send 1 message the same Android device (ok) and 2 messages for the same iOS device (not ok)
Shouldn't the old iOS instanceID be NOT_REGISTER like it happens on Android?
Eventually the old Instance ID will be invalidated as well. However if you generate a new Instance ID you should replace the old one with the new one and stop sending to the old one. Also if you send to the old one, you should get a canonical id in the response indicating which token to use instead of the old one you just used.
I have just implemented Parse Push notifications in my apps and everything is working just fine. However, before release I need to migrate the apps to different Parse apps for various reasons. But when I change the keys to the new Parse apps my devices don't receive the pushes from the new Parse app until I uninstall and re-install the app. This is a problem for our existing users in the field, who in general will be installing updates without uninstalling first.
Is there any way to delete the cached registration associated with the old Parse app before initializing with the new? I assume that would take care of the problem.
Christine
My mistake. Since the apps in the field are not currently registered for Parse Push Notifications switching to a new Parse app is not a problem for us. It is only if an app is already registered for Push Notifications that changing to a new Parse app requires uninstallation and re-installation before it will receive notifications from the new Parse app.
I am using gcm in my application.
In Google Developers Console page, I created a project and obtained a project id:
Using this project id in my application, the user gets registered to the gcm servers and obtain a registeration id. Then it is sent to my 3rd party server to be stored.
When 3rd party server wants to send message to the user, it uses the apikey I've obtained in the Google Developer Console page in the header of the post action and uses ther registeration id that has been stored for this particular user. The api key I'm using is from:
Please note that it's the key for server applications and the way i'm using this information is as just as I explained.
Everything works fine, messages are retrieved by the correct users and so on.I'm planning to deploy my app on google play but what is written in the section:GCM advanced topics confuses me. it says :
When an application is updated, it should invalidate its existing registration ID, as it is not guaranteed to work with the new version
and on the comment section of the sample code in Implementing GCM client sample code there is this comment:
// Check if app was updated; if so, it must clear the registration ID
// since the existing regID is not guaranteed to work with the new
// app version.
What is meant by these two explanations? I thought unless I press regenerate key here:
my api key wouldn't change. Why should it (or does it really) change when I update my application? or am I getting something wrong?
You are mixing between two different terms - API key and Registration ID. You don't have to create a new API key when deploying a new version.
What Google recommend to do (in the quotes you included above) is to re-register each device that installs the new version to GCM (and not rely on a previously obtained Registration ID), because the existing Registration ID assigned to the device for your application is not guaranteed to work for the new version of the app.