pushy / pushy-demo-android

A demo of the Pushy Android SDK integrated into a sample Android app.
Apache License 2.0
21 stars 9 forks source link

firebase and pushy notifications are not in sync #16

Closed PristynCareMohit closed 3 years ago

PristynCareMohit commented 3 years ago

Hi @PristynCareMohit, We're not entirely sure what you mean as the Pushy Android Demo project is not set up to receive notifications via Firebase. If you have a general inquiry regarding your own project, please reach out to support via e-mail at support@pushy.me.

Originally posted by @pushy-me in https://github.com/pushy-me/pushy-demo-android/issues/15#issuecomment-874155850

PristynCareMohit commented 3 years ago

This is regarding an issue we are facing in your Android SDK. After implementing pushy android SDK in one of our project we encounter an issue of receiving the same notification twice i.e. from Firebase and pushy both, they are not in sync, followed all the steps mentioned in your documentation ref: https://pushy.me/docs/resources/fcm-fallback-delivery

pushy commented 3 years ago

Hi @PristynCareMohit, Please paste the entire contents of your AndroidManifest.xml, or send it to support@pushy.me so we can investigate further.

PristynCareMohit commented 3 years ago

Hi @pushy-me,

Please find the below code of AndroidManifest.xml for your investigation.

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.health.care.mohit">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<uses-feature android:name="android.hardware.camera.any" />

<application
    android:name=".StartBDApp"
    android:allowBackup="false"
    android:fullBackupOnly="false"
    android:hardwareAccelerated="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:networkSecurityConfig="@xml/network_security_config"
    android:requestLegacyExternalStorage="true"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme2"
    tools:ignore="GoogleAppIndexingWarning"
    tools:replace="android:allowBackup">
    <activity android:name=".ui.common.CameraActivity" />
    <activity
        android:name=".ui.messaging.sms.SendSmsActivity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme" />
    <activity
        android:name=".ui.messaging.chat_message.ChatMessageActivity"
        android:launchMode="singleTop"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme" />
    <activity
        android:name=".ui.messaging.chat.ChatActivity"
        android:launchMode="singleTop"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme" />
    <activity android:name=".ui.messaging.template.MessageTemplateActivity" />
    <activity android:name=".calls.ActivityUpdateAlternateNumber" />
    <activity android:name=".calls.ActivityEnquiries" />
    <activity
        android:name=".calls.ActivityPlayRecording"
        android:launchMode="singleTask" />
    <activity android:name=".calls.ActivityCalls" />
    <activity android:name=".utils.BdActivity" />
    <activity
        android:name=".ui.home.HomeActivity"
        android:launchMode="singleTask"
        android:screenOrientation="portrait" />
    <activity
        android:name=".ui.common.LeadsActivity"
        android:launchMode="singleTop"
        android:screenOrientation="portrait" />
    <activity
        android:name=".ui.kyc.KycActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".ui.diagnostics.attachment.EditDiagnosticActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".ui.splash.SplashActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.PatientJourneyActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.MainActivity"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".activities.CreateLeadActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".ui.insurance.InsuranceActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".ui.appointments.AppointmentsActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.PreAuthImageWebView"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.DocScheduleActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.MyVersion"
        android:screenOrientation="portrait" />
    <activity
        android:name=".ui.all_opd.AllOpdActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".ui.all_ipd.AllIpdActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".ui.diagnostics.DiagnosticActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.PreAuthFormAttachmentActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".ui.login.LoginActivity"
        android:launchMode="singleTop"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme2.Login"
        tools:ignore="LockedOrientationActivity" />

    <service android:name=".fcm.BdParseFirebaseMessagingService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>
    <service
        android:name="com.parse.fcm.ParseFirebaseMessagingService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

    <meta-data
        android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@drawable/ic_notification_important" />
    <meta-data
        android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/colorAccent" />

    <receiver
        android:name="com.parse.ParsePushBroadcastReceiver"
        android:exported="false">
        <intent-filter>
            <action android:name="com.parse.push.intent.RECEIVE" />
            <action android:name="com.parse.push.intent.DELETE" />
            <action android:name="com.parse.push.intent.OPEN" />
        </intent-filter>
    </receiver>
    <receiver android:name=".receivers.CallReceiver">
        <intent-filter>
            <action android:name="android.intent.action.PHONE_STATE" />
        </intent-filter>
    </receiver>

    <service
        android:name=".service.CallStateChangedService"
        android:enabled="true"
        android:exported="false" />

    <receiver
        android:name=".fcm.CallReceiver"
        android:exported="true">
        <intent-filter>
            <action android:name="android.permission.READ_CALL_LOG" />
            <action android:name="android.intent.action.PHONE_STATE" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
        </intent-filter>
    </receiver>

    <provider
        android:name="androidx.core.content.FileProvider"
        android:authorities="${applicationId}.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths" />
    </provider>

    <service
        android:name=".service.NetworkCallbackService"
        android:enabled="true"
        android:exported="true" />

    <!-- Pushy Declarations -->

    <!-- Pushy Notification Receiver -->
    <!-- Incoming push notifications will invoke the following BroadcastReceiver -->
    <receiver
        android:name=".fcm.PushyReceiver"
        android:exported="false">
        <intent-filter>
            <!-- Do not modify this -->
            <action android:name="pushy.me" />
        </intent-filter>
    </receiver>

    <!-- Pushy Update Receiver -->
    <!-- Do not modify - internal BroadcastReceiver that restarts the listener service -->
    <receiver
        android:name="me.pushy.sdk.receivers.PushyUpdateReceiver"
        android:exported="false">
        <intent-filter>
            <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
        </intent-filter>
    </receiver>

    <!-- Pushy Boot Receiver -->
    <!-- Do not modify - internal BroadcastReceiver that restarts the listener service -->
    <receiver
        android:name="me.pushy.sdk.receivers.PushyBootReceiver"
        android:exported="false">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

    <!-- Pushy Socket Service -->
    <!-- Do not modify - internal service -->
    <service
        android:name="me.pushy.sdk.services.PushySocketService"
        android:stopWithTask="false" />

    <!-- Pushy Job Service (added in Pushy SDK 1.0.35) -->
    <!-- Do not modify - internal service -->
    <service
        android:name="me.pushy.sdk.services.PushyJobService"
        android:permission="android.permission.BIND_JOB_SERVICE"
        android:stopWithTask="false" />

    <!-- Pushy Firebase Service -->
    <service
        android:name="me.pushy.sdk.services.PushyFirebaseService"
        android:exported="false"
        android:stopWithTask="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

    <!-- End Pushy Declarations -->

</application>

pushy commented 3 years ago

Hi @PrisynCareMohit, You have 3 separate <service> declarations all listening to the com.google.firebase.MESSAGING_EVENT, causing multiple notifications to be emitted when an FCM notification comes in.

Please remove these lines of code from your AndroidManifest.xml to resolve the issue:

    <service android:name=".fcm.BdParseFirebaseMessagingService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>
    <service
        android:name="com.parse.fcm.ParseFirebaseMessagingService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>