Notification duplicate on android
When i send remove notification - i receive it, but rn-notification also shows it in notification center, even though i didn't call localNotification(). Any ideas what could go wrong?
@avdept, this is because library internally calls the local notification.
See code postNotification(null); in the file PushNotification.java on line 60.
This code still has some issue, but for now, you can just comment that line.
I will soon create PR for the same.
Thanks
@BhadraSoft however, when I called localNotification(). I get 2 notifications instead of 1. any Idea why?
I noticed the NotificationsAndroid ReceivedListener got 2 messages, I am guessing the app listens to GCM and FCM.
any Ideas?
@Jp3rd, Can you please attach your AndroidManifest.xml file. There might be the issue regarding the setup.
@BhadraSoft my bad, here you go
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sg.flair.android"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="23" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme"
xmlns:tools="http:/schemas.android.com/tools"
>
<meta-data android:name="com.wix.reactnativenotifications.gcmSenderId" android:value="786882185947\0"/>
<service
android:name="com.robinpowered.react.Intercom.IntercomIntentService"
android:exported="false">
<intent-filter
android:priority="999">
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
</intent-filter>
</service>
<receiver
android:name="io.intercom.android.sdk.push.IntercomPushBroadcastReceiver"
tools:replace="android:exported" />
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
</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:scheme="flairapp"/>
<data android:scheme="flairapp" android:host="login"/>
<data android:scheme="flairapp" android:host="logout"/>
</intent-filter>
<intent-filter>
<action android:name="fcm.flair.notification" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data
android:name="io.fabric.ApiKey"
android:value="3b55e16b67d026d4cf89e8c35ff7e67323d2a1b2"
/>
</application>
</manifest>
@Jp3rd ,
Thanks for sharing file. You can try following things for the issue related to FCM and GCM.
- If you are calling the local notification where the push notification is received, try removing the code for the local notification. If you still get the notification, then follow the solution provided in an earlier answer.
2.If a problem persists, It might be an issue regarding the both having FCM and GCM configuration, In that case, you can try upgrading project to FCM from GCM.
If you need assistance with your code, you can drop me a mail @ [email protected].
Thanks BhardaSoft
@BhadraSoft thanks for the advices!
so I what I did was:
- Removing the local notification, and it did not show, but the listener functions still runs twice.
- I checked on the android side, OnMessageReceived function, it only runs once.
So in conclusion, FCM and GCM wasn't the problem.
so, I am guessing its an issue where react native/the lib already called the function and this library called it again. So I'm trying to find out that problem.
Update
solved the problem, it was a saga issue i had, my bad.
@Jp3rd how did you solved this? I have this issue
Ive just solved this, for me it was a duplicate of permissions in my androidManifest.xml
I had to remove
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
from AndroidManifest.xml
I had to remove
<receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="${applicationId}" /> </intent-filter> </receiver>from AndroidManifest.xml
This worked for me, thanks
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
The issue has been closed for inactivity.
It seems to be double notification receiver: FCM and GCM. Solution of @abhaykumar1415 work for me
when I register in app first time,i received one notification and after that I register in app again and send notification twice and increase notification for every register in app.
@mahsabeyghole +1
This is exactly what I'm experiencing.