When I was using Parse from Facebook, I could test notification while in development (i.e. no app on the Play Store). But right now I am trying to implement Firebase into my app. My app is not published yet. I am done with android side implementation and am trying to send a notification from the Firebase console to my app. But my device never receives the notification. Why is that? I am targeting "All Users" because firebase does not have a version or any of my topics.
OKAY
So I did some more troubleshooting and here it is: my device is receiving notifications, but it's doing so weirdly:
when the app is open and the user is interacting with it, the notification goes through the expected pathway of calling onMessageReceived.
When the app is closed (not in recent apps either), the notification skips calling onMessageReceived and displays a notification in the status bar.
But then here is the log from FireBase when onMessageReceived is skipped
05-24 07:15:52.842 D/TimaKeyStoreProvider: TimaSignature is unavailable
05-24 07:15:52.842 D/ActivityThread: Added TimaKeyStore provider
05-24 07:15:53.102 D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
05-24 07:15:53.132 D/FirebaseApp: Initialized class com.google.firebase.iid.FirebaseInstanceId.
05-24 07:15:53.142 D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
05-24 07:15:53.222 I/FA: App measurement is starting up, version: 9080
05-24 07:15:53.222 I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
05-24 07:15:53.352 D/FirebaseApp: Initialized class com.google.android.gms.measurement.AppMeasurement.
05-24 07:15:53.352 I/FirebaseInitProvider: FirebaseApp initialization successful
05-24 07:15:53.372 D/AlgorithmsProvider: onCreate
05-24 07:15:53.452 I/FA: Tag Manager is not found and thus will not be used
For the display-messages (messages with notification tag), it's the expected behaviour that the onMessageReceived only called when the app is on foreground.
If you want to use data-messages (message without notification tag), you can't do it via console (at least until this time). You have to manually create post request to FCM server. You can see that post request example from answer to this question How to handle notification when app in background in Firebase.
Related
I did setup for firebase in App messaging. Created campaign and my app can't deliver it.
In logcat I got following logs
2019-02-26 11:22:40.616 16131-16131/app.package.name I/FIAM.Headless: Starting InAppMessaging runtime with Instance ID ciy4xtnJqBQ
2019-02-26 11:22:42.153 16131-16131/app.package.name I/FIAM.Headless: Setting display event listener
2019-02-26 11:22:42.457 16131-16131/app.package.name I/FIAM.Headless: went foreground
2019-02-26 11:22:42.464 16131-16157/app.package.name I/FIAM.Headless: Forcing fetch from service rather than cache. Test Device: false | App Fresh Install: true
2019-02-26 11:22:42.472 16131-16157/app.package.name W/FIAM.Headless: Recoverable exception while reading cache: /data/user/0/app.package.name/files/fiam_impressions_store_file: open failed: ENOENT (No such file or directory)
2019-02-26 11:22:42.483 16131-16157/app.package.name I/FIAM.Headless: Fetching campaigns from service.
2019-02-26 11:22:42.999 16131-16157/app.package.name W/FIAM.Headless: Service fetch error: PERMISSION_DENIED: Requests to this API firebaseinappmessaging.googleapis.com method google.internal.firebase.inappmessaging.v1.sdkserving.InAppMessagingSdkServing.FetchEligibleCampaigns are blocked.
Setup
Android studio 3.3.1
com.google.firebase:firebase-inappmessaging-display:17.0.5
com.google.firebase:firebase-core:16.0.7
Firebase in app messaging API enabled in Google Cloud Console
What could be reason of?
2019-02-26 11:22:42.999 16131-16157/app.package.name W/FIAM.Headless: Service fetch error: PERMISSION_DENIED: Requests to this API firebaseinappmessaging.googleapis.com method google.internal.firebase.inappmessaging.v1.sdkserving.InAppMessagingSdkServing.FetchEligibleCampaigns are blocked.
The reason of the issue was restriction on API key for Android app. So InAppMessaging API was enabled for the whole project but it also require add InAppMessaging API to the specific platform API key restriction.
you have to add the firebase InApp Messaging permission to your Google Cloud API, can be done from the Google Cloud Console
I just created my release candidate with Android Studio in release mode and generating a signed apk. Everything fine, but when I test it in my device or other devices, the app starts and just shows a blank screen. No login screen, nothing.
The logs of the release version doesn't say anything to me. It's the first time that happens to me after 4 years of app development. I don't really understand what's going on.
I've also tried the rolling back to the version that we have in Google Play Store, same happens. Debug working fine, Release signed not working.
I tried it with another computer and another phone, same issues.
I will appreciate any help, because I never felt that lost.
These are the logs
09-13 17:27:07.837 16977-16977/? I/applabs.sharif: Late-enabling -Xcheck:jni
09-13 17:27:07.918 16977-16977/es.sharifyapplabs.sharify I/applabs.sharif: The ClassLoaderContext is a special shared library.
09-13 17:27:08.052 16977-16977/es.sharifyapplabs.sharify I/MultiDex: VM with version 2.1.0 has multidex support
Installing application
VM has multidex support, MultiDex support library is disabled.
Installing application
VM has multidex support, MultiDex support library is disabled.
09-13 17:27:08.080 16977-16977/es.sharifyapplabs.sharify D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
09-13 17:27:08.096 16977-16977/es.sharifyapplabs.sharify I/FirebaseInitProvider: FirebaseApp initialization successful
09-13 17:27:08.138 16977-16977/es.sharifyapplabs.sharify I/CrashlyticsCore: Initializing Crashlytics 2.6.1.23
09-13 17:27:08.151 16977-16977/es.sharifyapplabs.sharify I/CrashlyticsInitProvider: CrashlyticsInitProvider initialization successful
09-13 17:27:08.168 16977-16977/es.sharifyapplabs.sharify E/com.facebook.internal.a: getAttributionIdentifiers should not be called from the main thread
09-13 17:27:08.178 16977-17019/es.sharifyapplabs.sharify D/NetworkSecurityConfig: No Network Security Config specified, using platform default
09-13 17:27:08.276 16977-17002/es.sharifyapplabs.sharify I/FA: App measurement is starting up, version: 12451
To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app es.sharifyapplabs.sharify
09-13 17:27:18.273 16977-17014/es.sharifyapplabs.sharify W/Fabric: Could not call getAdvertisingIdInfo on com.google.android.gms.ads.identifier.AdvertisingIdClient
09-13 17:27:18.274 16977-17014/es.sharifyapplabs.sharify W/Fabric: Could not call getId on com.google.android.gms.ads.identifier.AdvertisingIdClient$Info
09-13 17:27:28.333 16977-17014/es.sharifyapplabs.sharify W/Fabric: Could not call getAdvertisingIdInfo on com.google.android.gms.ads.identifier.AdvertisingIdClient
09-13 17:27:28.334 16977-17014/es.sharifyapplabs.sharify W/Fabric: Could not call isLimitAdTrackingEnabled on com.google.android.gms.ads.identifier.AdvertisingIdClient$Info
09-13 17:27:28.658 16977-17006/es.sharifyapplabs.sharify D/skia: --- Failed to create image decoder with message 'unimplemented'
09-13 17:27:29.907 16977-17006/es.sharifyapplabs.sharify W/CrashlyticsCore: Expected method missing: registerOnMeasurementEventListener
java.lang.NoSuchMethodException: parameter type is null
at java.lang.Class.getMethod(Class.java:2060)
at java.lang.Class.getDeclaredMethod(Class.java:2047)
at com.crashlytics.android.c.u.a(DefaultAppMeasurementEventListenerRegistrar.java:89)
at com.crashlytics.android.c.u.a(DefaultAppMeasurementEventListenerRegistrar.java:54)
at com.crashlytics.android.c.k.a(CrashlyticsController.java:1574)
at com.crashlytics.android.c.l.d(CrashlyticsCore.java:320)
at com.crashlytics.android.c.l.e(CrashlyticsCore.java:44)
at c.a.a.a.h.a(InitializationTask.java:63)
at c.a.a.a.h.a(InitializationTask.java:28)
at c.a.a.a.a.c.a$2.call(AsyncTask.java:311)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
09-13 17:27:38.083 16977-16996/es.sharifyapplabs.sharify E/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE
09-13 17:28:38.101 16977-16996/es.sharifyapplabs.sharify E/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE
09-13 17:30:08.126 16977-16996/es.sharifyapplabs.sharify E/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE
1) Invalidate Cache/Restart Android Studio.
2) Refresh Build completely, Sign Apk & test!
I just found the solution. Basically Facebook messed up again.
Related to the dependency in gradle.
App getting stuck with E/com.facebook.internal.AttributionIdentifiers
I have an app that is modularized to support instant-apps.
App modules:
app
instantapp
base
main
detail
search
I tried to add Firebase by adding:
classpath 'com.google.gms:google-services:3.1.1' → to the Project Level build.gradle
api "com.google.firebase:firebase-core:${versions.firebase}" → to the Base Module
apply plugin: 'com.google.gms.google-services' → to the bottom of the Base Module
google-services.json → to the base module folder
When I run the non-instant app I receive the following errors:
I/FirebaseInitProvider: FirebaseApp initialization unsuccessful
E/FA: GoogleService failed to initialize, status: 10, Missing google app id value from from string resources with name google_app_id.
I/FA: App measurement is starting up, version: 11720
I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.punpuf.chacaraselazer.app
E/FA: Missing google_app_id. Firebase Analytics disabled. See https://goo(...)
E/FA: Uploading is not possible. App measurement disabled
I/FA: Tag Manager is not found and thus will not be used
And when I run the instant app I receive the following error:
V/FA: Cancelling job. JobID: 1799580119
E/FirebaseApp: Firebase API initialization failure. (...) Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void android.app.job.IJobScheduler.cancel(int)' on a null object reference
I/FirebaseInitProvider: FirebaseApp initialization successful
If I add the following line: "FirebaseAnalytics.getInstance(this)", not only does it receive the previous errors, it also crashes:
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.punpuf.chacaraselazer.app, PID: 11273 java.lang.RuntimeException: Unable to start activity ComponentInfo{(...)}: java.lang.NullPointerException: Attempt to invoke interface method 'void android.app.job.IJobScheduler.cancel(int)' on a null object reference
So my question is how can I get Firebase Analytics to work, and not crash on both my instant and non-instant version of my app.
Although this question is a bit similar to FirebaseApp initialization unsuccessful in Android Instant apps , mine not contain the same type of errors.
Update:
I've created a new Firebase Project, and updated my google-services.json, but still didn't work.
Here are my gradle files:
project: https://gist.github.com/Punpuf/8582fa3610a1c3dea13627e1207a6064
app: https://gist.github.com/Punpuf/2104ffe0c90927cb79944860a7cb6c46
instantapp: https://gist.github.com/Punpuf/233d96e91293a2a14e8fdf50092edd2d
base: https://gist.github.com/Punpuf/e1646f67d8a6094773c390d2df209eae
main: https://gist.github.com/Punpuf/f8bdd8789b11d274afdb1c51f490ed25
detail: https://gist.github.com/Punpuf/0a4f87b4fb512557ffe6cd110ce667de
search: https://gist.github.com/Punpuf/455e28b38baad23294dda6c9592586a2
I've also tried replacing firebase analytics dependency with firebase messaging and I still received the "FirebaseApp initialization unsuccessful" error.
I've had the same problem, I solved it adding the google-services.json to both base and app module and applying the google services plugin in both build.gradle files
Before adding firebase analytics my app worked really fast. It has a lot of request which are sequential.
However, as soon as I added firebase analytics my app's internet requests froze and I got a lot of logs which consume time for no purpose.
W/System: ClassLoader referenced unknown path: /data/app/my.project.-1/lib/arm64
W/art: Verification of void my.project.App.<init>() took 133.425ms
D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
D/FirebaseApp: Initialized class com.google.firebase.iid.FirebaseInstanceId.
V/GoogleSignatureVerifier: com.google.android.gms signature not valid. Found: <Some big sequence of characters>
I/FA: Tag Manager is not found and thus will not be used
D/ChimeraCfgMgr: Reading stored module config
I/DynamiteModule: Considering local module com.google.android.gms.crash:0 and remote module com.google.android.gms.crash:2
D/ChimeraFileApk: Primary ABI of requesting process is arm64-v8a
D/FirebaseCrashReceiverServiceImpl: onCreate
I/DynamiteModule: Selected remote version of com.google.android.gms.flags, version >= 1
This is quite important, because I wait about 5-6 seconds until my own requests start to execute.
I have trouble with getting my cordova/ionic android app to work with google analytics.
For now I have tried GAPlugin with anulartics without success, and now I am trying simpler setup with https://github.com/danwilson/google-analytics-plugin
In my ionic angular app, I have added following code in
.run(function($ionicPlatform) {
if (typeof analytics !== 'undefined'){
analytics.startTrackerWithId('UA-55MYNUMB8-1');
analytics.trackView('testapmain');
console.log("starting analytics");
analytics.debugMode()
}
else
{
console.log("Google Analytics plugin could not be loaded.")
}
}
and it seems to be workling correctly, following is output of adb -s BH9XXXXJ0D logcat | grep GAV3
looks like it connects to google analytics, sends message
V/GAV3 (12570): Thread[client_id_fetcher,5,main]: Storing clientId.
I/GAV3 (12703): Thread[GAThread,5,main]: No campaign data found.
V/GAV3 (12570): Thread[GAThread,5,main]: connecting to Analytics service
V/GAV3 (12570): Thread[main,5,main]: service connected, binder: android.os.BinderProxy#4483eda8
V/GAV3 (12570): Thread[main,5,main]: bound to service
V/GAV3 (12570): Thread[GAThread,5,main]: connect: bindService returned true for Intent { act=com.google.android.gms.analytics.service.START cmp=com.google.android.gms/.analytics.service.AnalyticsService (has extras) }
V/GAV3 (12570): Thread[GAThread,5,main]: Loaded clientId
V/GAV3 (12570): Thread[main,5,main]: Connected to service
I/GAV3 (12570): Thread[GAThread,5,main]: No campaign data found.
V/GAV3 (12570): Thread[GAThread,5,main]: putHit called
V/GAV3 (12570): Thread[GAThread,5,main]: Sending hit to service PATH: https: PARAMS: v=1, ul=en-us, t=appview, ht=1412010481966, sr=1080x1776, an=testa, tid=UA-55215798-3, aid=com.ionicframework.testa300342, cid=05b7c4d9-b3b3-4ea8-9f04-dfa61c6853ec, av=0.0.1, _u=.KnoK-AL, cd=testapmain,
but nothing shows up in google analytics. Google analytic property is set as Mobile App.
ionic is 2.5
cordova 3.6.3-0.2.13
android 4.4.4
phone xperia z1
javac 1.7.0_65 OpenJDK Runtime Environment (IcedTea 2.5.2) (7u65-2.5.2-3~14.04)
on Ubuntu 14.04 64bit
Any idea what might be wrong? Or how to debug it more to see if google analytics is receiving my messages?
Looks like it was my own wishful thinking at fault. While it is said in documentation that app data will appear in analytics only after 24 hours, I somehow thought that it does not apply to 'Real-time' tab. It does. After 24 hours, Realtime data shows up with delay of seconds, but not earlier.
Some answers in related questions claim the opposite. Do not take it for granted, as I did.