I am trying to send notifications from Firebase to an Android mobile app developed in Visual Studio 2015.
I tried to implement each step that is presented in this tutorial, but I still can't receive notifications.
One weird thing that I noticed is related to this part of the tutorial:
Log.Debug(TAG, "google app id: " + Resource.String.google_app_id);
The google_app_id value logged to the output window should match the mobilesdk_app_id value recorded in google-services.json.
The result of the log that I quotted above doesn't match the mobilesdk_app_id value recorded in google-services.json, although I made every step presented in the tutorial.
Also, when I try to send notification that has the target set to "single device" and I write in the FCM registration token the result of the FirebaseInstanceId.Instance.Token, the message status is "failed" (Unregistered registration token).
How can I fix this issues?
Later edit:
The difference between the possible duplicate post and mine is that my FirebaseInstanceId.Instance.Token is not equal to mobilesdk_app_id value recorded in google-services.json.
Any ideas?
Content of manifest file (between application tags):
<application android:label="RTSD_Firebase">
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
android:exported="false" />
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
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" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
</application>
Related
I have a problem with dynamic link at Firebase not redirecting me to Play Store if the application is not installed.
The dynamic link is defined as following:
The link preview (debug) show following picture:
according to this one if I click on the link and application is not installed I would be brought to Play Store. However it just opens a browser and opens the web link. The "Play Store" link though is functioning and brings me to the Play Store.
One more detail. When I click on the dynamic link on my Android phone I see three steps:
A browser window with "google.com" URL opens shortly.
Browser window is closed and I see original screen where I clicked on the link with a ring rotating for less than a second.
A browser windows opens again but this time with web link opened
And same happens even if the application is installed.
Is there a way to debug this behavior and get some better understanding of what's the reason?
The AndroidManifest.xml is defined as following:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp">
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.camera.flash" />
<application
android:label="myapp"
android:name="${applicationName}"
android:icon="#mipmap/icon">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Deep linking -->
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="myapp.com" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
As you mentioned it is in debug , i believe here that application is not present on playstore right now and that's why it is not redirecting you to playstore in case of app is not installed on your device but yes , it should open your app if it is already installed on your device
so make sure above scenario .. if flow is working same as mentioned then no worries everything is fine but if it is not working as mentioned then you need to mention code of creating link , manifest file , activity where you are handling it etc ..
So, it turned out my approach to dynamic links building was wrong. Dynamik link creation as shown in the question is a way to establish static links that don't change and have no parameters. It's usable to bring users to a specific part of your application that never changes.
In case of using dynamic link, which is dynamic in its nature like in my case - invitation link that allows to install application if it's not yet installed, run it and bring the user to a specific part of the application with parameters would be:
Define a URL prefix
Publish the application at Play Store at least in closed testing mode. Internal testing seems not to be enough because it's available only by internal testing ID and not the package ID.
Generate URL of type: https://myapp.page.link/?link=https://myapp.com/join/invitation_id&apn=com.myapp
That is enough to make work for Android. For iOS it's not tackled yet.
I have been trying to publish an Android automotive application to Google Play Store, but it was rejected. The reason for the rejection was "App category not permitted. At this time, we are only accepting apps within categories supported by the Android for Cars App Library as well as the Media and Video categories."
The categories referenced above are Media apps (audio), Messaging apps, Navigation apps, Point of Interest (POI) apps and Video apps (https://developer.android.com/training/cars#supported-app-categories).
In our AndroidManifest.xml file, the category is defined like this :
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="androidx.car.app.category.POI" />
</intent-filter>
<meta-data android:name="distractionOptimized" android:value="true" />
</activity>
So my question is, why does it say it was rejected due to "..only accepting apps within categories supported by the Android for Cars App Library as well as the Media and Video categories", when the category for the application is one of these categories?
I tried to appeal, but it says it can take up to 7 days, and it would be great knowing why as soon as possible.
I have tried to search for an answer, but I have not found anything in particular.
The only thing I noticed, was that other people put their category inside , like this:
<service
android:name=".MyCarAppService"
android:exported="true">
<intent-filter>
<action android:name="androidx.car.app.CarAppService"/>
<category android:name="androidx.car.app.category.POI"/>
</intent-filter>
</service>
However, I have found that this is not always the case. An example in the documentation which does not use the (https://developer.android.com/reference/androidx/car/app/activity/CarAppActivity), says:
"The class representing a car app activity in the main display. This class is responsible for binding to the host and rendering the content given by its androidx.car.app.CarAppService."
And in the example provided, the code looks like this:
<activity
android:name="androidx.car.app.activity.CarAppActivity"
android:exported="true"
android:launchMode="singleTask"
android:label="#string/your_app_label">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="distractionOptimized" android:value="true"/>
</activity>
So my question remains; why does my app get rejected due to "not having a supported category", when the category is set to one of the five supported categories?
Final answer:
Check your androidx.car.app library version to determine which category to use if you're building a Point-Of-Interest app:
Lower than 1.3: Use PARKING or CHARGING categories.
1.3 and up: Use POI category
We ended up using the new IOT category as that suited our app best, it worked with version 1.2 of the CarApp library, it passed the review for open testing (1.3 wasn't available yet on Xamarin at the time of writing this update).
*** Original post: ***
Unfortunately, this seems to be a common problem a lot of people are having that are trying to publish Android Auto apps. See this Stack Overflow thread.
I'm also using the "androidx.car.app.category.POI" category since my app definitely does not fall under any of the other categories. Out of the 7 submissions I've done, only 3 have been approved so far, it seems the approvals are very sporadic. The rejection always has the same generic rejection message ("App category not permitted"). When you appeal the rejection, they just respond with the same rejection message.
New categories can be requested for Android Auto using this URL.
Edit:
This Stack Overflow thread suggested using the PARKING category instead of POI. Which is interesting because according to Google's Android for cars docs, the PARKING and CHARGING categories have been deprecated and should use POI instead now. I tried it and my build got approved.
I have a problem receiving any tokens or push notifications with my custom FirebaseMessagingService, after i disabled the auto initialisation of firebase messaging by setting the key firebase_messaging_auto_init_enabled to false in my AndroidManifest.xml.
When not setting the key to false my Service does receive a token.
I mean it is obvious, that i do need to initialise firebase messaging in order to retrieve a token, but all methods i tried did not seems to work.
In order to prevent legal problems i only want to enable firebase/server communication after the user of my Android app did accept the terms of use.
That is why i want to prevent the auto initialisation. After the user did accept the terms of use i want initialise the app and send my retrieved token to my backend.
Methods i already tried:
FirebaseApp.initializeApp(<Context>)
FirebaseMessaging.getInstance().setAutoInitEnabled(true)
I can actually get a token by using the method FirebaseInstanceId.getInstance().getInstance() but i would really prefer to use my FirebaseMessagingService which seems to be the much cleaner way.
Here is some of the code in my AndroidManifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:usesCleartextTraffic="true">
<meta-data
android:name="firebase_messaging_auto_init_enabled"
android:value="false" />
<meta-data
android:name="firebase_analytics_collection_enabled"
android:value="false" />
<service
android:name="de.itkl.smartmobile.module.push.implementation.SMPushMessageService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
</application>
</manifest>
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 would like to add Push messaging to my Phonegap Android App and believe that C2DM is the waybest way to make this work - could point me in the right direction to set this up?
Is there a plugin or tutorial to help with this?
Also - do I actually need a plugin - is it possible to add C2dm to my app the traditional Android way without messing up my phonegap setup?
Yes, C2DM is the Android Push solution. On https://github.com/awysocki/C2DM-PhoneGap you can find an example implementation.
The files in the com.google namespace have to be included unchanged, they are from the session "Google IO Session Overview: Android + App Engine: A Developer’s Dream Combination", see http://bradabrams.com/2011/05/google-io-session-overview-android-app-engine-a-developers-dream-combination/
So these are the steps you should perform:
Add the 3 com.google classes to your project
Create a class called C2DMReceiver (naming convention) which inherits from C2DMBaseReceiver and implement the necessary abstract events
Set up the AndroidManifest.xml
The AndroidManifest looks like
<!-- set up an own permission to secure our C2DM mesages -->
<permission android:name="your.namespace.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<!-- List of permission -->
<uses-permission android:name="your.namespace.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application ..>
<!-- Your implementation of the class C2DMReceiver, base class is Googles C2DMBaseReceiver -->
<service android:name=".C2DMReceiver" />
<!-- Googles broadcast receiver, it delegates to your.namespace.C2DMReceiver -->
<receiver
android:name="com.google.android.c2dm.C2DMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="your.namespace" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="your.namespace" />
</intent-filter>
</receiver>
</application>
If you receive on the emulator the error "E/CSE Notifications(401): Registration error ACCOUNT_MISSING", you have to add a Google account to your emulator.
For your second question: it depends what you want to do. When you receive the message and you just want to display a notification so that the user is able to start your app then you don't need a Phonegap plugin. In that case you can solve everything in java.
In case you get to this answer, notice C2DM is absolete and now you have to use GCM.
Moreover there is an official PhoneGap plugin supporting notification for both Android and iPhone. Check out the PushPlugin at https://github.com/phonegap-build/PushPlugin