I just updated GCM to FCM according to this guide here. The site says my service which extends FirebaseInstanceIdService will be called as soon as the token is generated. For some reason, my service is never called and onTokenRefresh is never executed.
My services are registered like this, according to the guide:
<service android:name=".fcm.FcmService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name=".fcm.InstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCEID_EVENT"/>
</intent-filter>
</service>
My service:
public class InstanceIdService extends FirebaseInstanceIdService {
private static final String TAG = "InstanceIdService";
#Override
public void onTokenRefresh() {
String token = FirebaseInstanceId.getInstance().getToken();
Log.e(TAG, "Got token: " + token);
}
}
The LogCat doesn't say anything about missing configuration files or else, and I can see logs about FirebaseApp and a Log entry mentioning the token, but still my service is never called.
Do I need to start this service somewhere in my activity?
Am I doing something wrong? Can someone guide me in the correct direction?
EDIT: using Log.e("TOKEN", "Token: " + FirebaseInstanceId.getInstance().getToken()); correctly prints my token, so that means it was generated successfully. The service still doesn't get called...
EDIT 2: Changing INSTANCEID_EVENT to INSTANCE_ID_EVENT fixed the issue, although I had to reinstall the app. As I already released a beta version containing the new FCM, my beta testers won't be able to subscribe to the topics to reveice incoming messages. So how should I solve that?
Thanks Endanke for figuring this out with me. It seems that the Firebase documentation is inconsistent. One page says your intent filter in your manifest file should be INSTANCE_ID_EVENT, and another says INSTANCEID_EVENT.
You should use INSTANCE_ID_EVENT, and once you make the change, you'll need to completely uninstall and reinstall your app for the changes to kick in.
FCM should be used as a replacement to GCM. In your case it looks like you have services for both FCM and GCM in your manifest. Try remove the gcm.GcmService, and only use the one that extends FirebaseInstanceId.
Make Sure that your Firebase "MyFirebaseInstanceIDService.java" file is directly under the package name tree "com.company"
Don't put them in the separate subpackage like "com.company.services". This is because your google-services.json will look for the files directly under "com.company" directory.
Add the following in your manifest application tag below meta tag (if any)
<service
android:name=".MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
You will get your TOKEN on the public void onTokenRefresh() method
PS: Download and replace the latest google-services.json from your project console.
After a ton of trial and error my issue was having tools:node="replace" in my application tag...removing it solved the issue for me
I had the same problem and by uninstalling and reinstalling the app on the device onTokenRefresh() got called once. So I guess it changed from GCM where it got called often to just getting called once when there actually is no token.
I've different build variants in my project and I've the following problem:
From: https://firebase.google.com/docs/android/setup#prerequisites
Note: If you have multiple build variants with different package names defined, each app must be added to your project in Firebase console.
Also, check the date of your phone! I once had a difference of 5-7 days! Fixing the day and reinstalling the app fixed this!
What 'Firebase Cloud Messaging' wants is:
Implement a derived class (MyFirebaseInstanceIdService) from
FirebaseInstanceIdService.
Implement the override onTokenRefresh to handle an update on the
token for the device.
In the AndroidManifest.xml reference the 'derived' class prefixed
with a ".".
MyFirebaseInstanceIdService is a 'suggested' name. I personally prefer to prefix such derived classes with an acronym or name that I use throughout the App.
onTokenRefresh() will call only one time.when your app is install first time, if you want to access token from other activity you have to call this method:
FirebaseInstanceId.getInstanceId().getToken();
just change the INSTANCE_ID_EVENT to INSTANCEID_EVENT .it worked for me
i am facing issue with registering device with GoogleCloudMessaging for push notifications
the source code can be found here:
https://github.com/ronenhamias/ezPushSDK-Android
the problem i am facing it that calling register to device returns null 70% of the times some time the registration succeed mainly when i am using the android studio emulator but when another developer runs the app or debugging it on a real device it returns null
please note that i created the project and got sender id and api key and was able to push with this keys several times.
for some reason the integration with the cloud returns null.no error is thrown, and no further information is provided
what can be the reasons for that?
Hope It work for You..
Please change
<receiver android:name=".gcm.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
TO
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
And If It not Then Use GCM.jar file and change IntentService to extends GCMBaseIntentService and use its default methods..
Its easy and simple to use..
and refer this link so You can easy to understand
I am trying to connect Google Now SEARCH_ACTION with my searchable activity using this piece of code in my AndroidManifest.xml:
<activity android:name=".SearchableActivity">
<intent-filter>
<action android:name="com.google.android.gms.actions.SEARCH_ACTION"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
I am following instructions on http://android-developers.blogspot.com/2014/10/the-fastest-route-between-voice-search.html and https://developer.android.com/guide/components/intents-common.html#SearchOnApp.
This is just not working. The search from Google Now is not launching my app. I have verified that:
This works for Eat 24 app, confirming that there's no issue with right version of OS/Google app/Locale.
I can launch app from inside my app and receive typed search queries, confirming that my SearchableActivity code doesn't have any issues.
Anyone has gotten this to work? Could you please let me know what I am missing here?
Well... looks like the app needs to be published on Play Store:
https://plus.google.com/+AndroidDevelopers/posts/afSRdDQiy1N - look for comments by Jarek Wilkiewicz. Going to try this next.
This is driving me really crazy. I am new to Android development but experienced in iOS development. I wanted to implement Parse Push notifications to an Android app and all is going fine:
The devices are registered at Parse
While sending a test Push message the Parse system tells me that the message is received
BUT: I don't receive anything on my Android test devices.
I have already created new Parse Apps and Android Studio projects but without any luck. Any help on debugging this or is this a Android studio related issue?
EDIT: I just followed the Push service quick guide so I added some lines to the Manifest and added this to my code
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_inlog);
Parse.initialize(this, "xxx", "xxx");
ParseFacebookUtils.initialize("1515015192073818");
ParseInstallation.getCurrentInstallation().saveInBackground();
Manifest:
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<!--
IMPORTANT: Change "com.parse.starter" to match your app's package name.
-->
<category android:name="com.pootentieel.andrew.sbpootentieel" />
</intent-filter>
</receiver>
Did you changed com.parse.starter to match your package name and have you registered push callback receiver activity?
EDIT:
goto this link github.com/ParsePlatform/PushTutorial and import the android project and change the keys. Then run the android project and send a push to see if it works. If it works check both the projects side by side to see what is causing the problem. Please mark this answer as correct if it helped thanks :)
I am trying to implement Fiksu SDK for Android and iOS.
I am able to add code to track registration and purchase :
FiksuTrackingManager.uploadRegistration(Context, FiksuTrackingManager.RegistrationEvent.EVENT1);
FiksuTrackingManager.uploadPurchase(Context, FiksuTrackingManager.PurchaseEvent.EVENT1, 0, "USD");
In iOS i am able to get the logs in the console, but in android i am only getting logs which event is called.How can i check the logs in Android ?
Also how to track the app events in Fiksu dashboard ?
They have also mentioned to add client id , from where will i get the client id ?
if any one has implemented it please guide me how to proceed ?
this might be too late but it may help someone that comes across this post.
I just had to integrate the Fiksu SDK for android for a client and face similar issues when testing.
How can i check the logs in Android ?
If the SDK has been properly installed you should be able to see some logs like below which means the events have been succesfully sent to their server.
11-25 10:04:31.010 21588-23132/ D/FiksuTracking? Event: Resume
11-25 10:04:32.320 21588-23132/ D/FiksuTracking? Successfully uploaded tracking information.
11-25 10:05:40.500 21588-23383/ D/FiksuTracking? Event: Purchase
11-25 10:05:42.180 21588-23383/ D/FiksuTracking? Successfully uploaded tracking information.
how to track the app events in Fiksu dashboard ?
This part is quite annoying as they don't have a way to create Apps in the dashboard and link them to your android app so you can see your events coming through. Instead you have to actually perform the test and send them an email for someone from Fiksu to check their servers and track your events.
These are the test steps as per their documentation:
Download and install your application on an Android device and perform your tests.
Fill a form they have and send it via email to their support team.
Someone will get back to you confirming if they have received your events.
They have also mentioned to add client id , from where will i get the client id ?
The clientId is just an identifier for your users within your app. In other words you can set that to whatever you want (e.i. email address). The suggestion is to set this after a user has registered or logged in in your app.
FiksuTrackingManager.setClientId(Context, "XXX");
Based on their documentation: "Where XXX would be the ID you want to send and can be any alphanumeric string up to 64 characters long. All events sent after this call is made would send the Client ID that has been set. If you call setClientID again it will overwrite whatever was there before. However the first Client ID sent with an event will be the Client ID that is in the export on the Fiksu Client Dashboard and it will not get updated."
if any one has implemented it please guide me how to proceed ?
So to sum up below are the steps to integrate the Fiksu SDK for android.
Downlaod the SDK.
Add the SDK jar to your project.
Set the isntall receiver (Only if you want to track app installs). NOTE that they expect to be the only receiver in the AndroidManifest.xml file. If you are using other third party SDKs to track the same you either:
Use fiksu to forward the intent:
<receiver android:name="com.fiksu.asotracking.InstallTracking"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
<!-- Forward to other receivers -->
<meta-data android:name="forward.1"
android:value="com.google.android.apps.analytics.AnalyticsReceiver" />
<meta-data android:name="forward.2" android:value="com.mypackage.thirdparty.MdotmReceiver" />
</receiver>
Or set the below flag in your AndroidManifest and have another install receiver forward it to the fiksu SDK.
<meta-data android:name="FiksuDisableReceiverCheck" android:value="true" />
Set the permissions in your AndroidManifest.
android.permission.INTERNET
android.permission.READ_PHONE_STATE
Initialize the SDK. Normally on your Application onCreate() method.
FiksuTrackingManager.initialize(this);
Setting up Google Play Services on your project.