Reputation: 171
I am currently building an android app with some FCM usage. Unfortunately I am not able to put this all together. I have connected firebase to my app successfully, .json file (generated by my API provider) is also well placed. If app is in foreground, onMessagReceived is called properly. Push notifications are also received properly, but click event on notification (while in background) does absolutely nothing. Notification disappears without opening launch activity. If I switch .json file to one that was generated by me with sample FCM app, click on notifications works in a desired way. I have no idea what is going on.
Below I present part of my AndroidManifest.xml with launcher activity/fcm services and .json file generated by my api provider (some data were changed, but particular values are equal):
<application
android:name=".xyz"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/xyz"
android:roundIcon="@mipmap/ic_launcher"
android:theme="@style/Theme.xyz.Light.DarkActionBar">
<activity
android:name=".views.activities.SplashActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.xyz.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="xyz.com"
android:pathPrefix="/api,xyz"
android:scheme="https"/>
<data
android:host="xyz.pl"
android:pathPrefix="/api,xzz"
android:scheme="https"/>
</intent-filter>
</activity>
...
<service android:name=".services.xyzFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name=".services.xyzFirebaseInstanceService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
</activity>
</application>
{
"project_info": {
"project_number": "123456789123",
"firebase_url": "https://xxx.firebaseio.com",
"project_id": "xxx",
"storage_bucket": "xxx.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:123456789123:android:a12a3456789012e1",
"android_client_info": {
"package_name": "com.mycompany.myapp"
}
},
"oauth_client": [
{
"client_id": "123456789123-zzz.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "current_key"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
I also include sample fcm message generated by my api provider.
[2017-11-02 12:10:06] https://fcm.googleapis.com/fcm/send
HEADERS: [
"Authorization:key=my_auth_key"
]
DATA: {
"notification": {
"icon": "https://www.myavatar.com/avatar.png",
"title": "Message title",
"body": "aaa",
"click_action": "https://www.app.com/notifications,open?_id=678696787lkju82"
},
"data": {
"date_create": "2017-11-02 12:10:04",
"sender_type": "user",
"sender_app_id": "2",
"sender_app_display": "MyApp",
"sender_user_id": "43",
"sender_display": "WK",
"type": "message"
},
"to": "fYqHDJEVUUM:APAasdasdasdHS_GOsen-kkjghkasjhd898098klj-8797hoijo8"
}
RESPONSE: {
"multicast_id": 556579726904--2753,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
{
"message_id": "0:1880938748%hkk4bjl2k1"
}
]
}
UPDATE
I've found the problem. The "click_action" parameter was causing the problem, my api provider set url address as value of this parameter to help himself on the web side and that was it ;) Big thanks to @Barns52 for giuding me to solution.
Upvotes: 3
Views: 5561
Reputation: 171
I've added this at the end of a post, but it probably should be here:
I've found the problem. The "click_action" parameter was causing the problem, my api provider set url address as value of this parameter to help himself on the web side and that was it ;) Big thanks to @Barns52 for giuding me to solution.
Upvotes: 3