urbanairship / urbanairship-cordova

Urban Airship integration with Apache Cordova
https://docs.airship.com/platform/mobile/setup/sdk/cordova/
Other
142 stars 149 forks source link

Unable to get background notification on Android #337

Closed florianchevallier closed 4 years ago

florianchevallier commented 4 years ago

❗For how-to inquiries involving Airship functionality or use cases, please contact (support)[https://support.airship.com/].

Preliminary Info

What Airship dependencies are you using?

"urbanairship-cordova": "^10.1.0" "@ionic-native/urbanairship": "^5.22.0", Capacitor on the master branch to be able to get Android X

What are the versions of any relevant development tools you are using?

Report

What unexpected behavior are you seeing?

Notifications works in foreground with iOS / Android Notifications works in bakcground with iOS Not on android

Strangely enough, it works well with FCM directly, using the GCM token from "Android Channel IDs"

What is the expected behavior?

Well I would be pleased if this would work on android as well

What are the steps to reproduce the unexpected behavior?

This issue : https://github.com/ionic-team/capacitor/issues/2511 sum ip all

here is the POST I'm doing with Postman :

{
    "audience": "all",
    "notification": {
        "alert": "Hey Android and iOS!!"
    },
    "device_types": [
        "android",
        "ios"
    ]
}

Do you have logging for the issue?

Here is the logcat I get when the app is in background :

2020-03-03 15:18:54.603 942-11391/? I//vendor/bin/hw/vendor.qti.hardware.servicetracker@1.0-service: bindService is called for service : com.google.android.gms/.gcm.PushMessagingRegistrarProxy and for client com.rmm.test.app
2020-03-03 15:18:54.603 942-11391/? I//vendor/bin/hw/vendor.qti.hardware.servicetracker@1.0-service: total connections for client : com.rmm.test.appare :2
2020-03-03 15:18:54.621 17488-17819/com.rmm.test.app V/Capacitor/Plugin/PushNotifications: Notifying listeners for event pushNotificationReceived
2020-03-03 15:18:54.630 942-11391/? I//vendor/bin/hw/vendor.qti.hardware.servicetracker@1.0-service: unbindService is called for service : com.google.android.gms/.gcm.PushMessagingRegistrarProxy and for client com.rmm.test.app
2020-03-03 15:18:54.630 942-11391/? I//vendor/bin/hw/vendor.qti.hardware.servicetracker@1.0-service: size of client connections for client: com.rmm.test.appafter removal is 1

Sometimes, this popup :

2020-03-03 15:20:54.679 18202-18269/com.rmm.test.app E/UALib: JobDispatcher - UAirship not ready. Rescheduling job: JobInfo{action=ACTION_SYNC_MESSAGE_STATE, id=9, extras='{}', airshipComponentName='com.urbanairship.richpush.RichPushInbox', isNetworkAccessRequired=false, initialDelay=0, persistent=false}

And, to compare, the one I get in foreground :

2020-03-03 15:19:29.330 942-11391/? I//vendor/bin/hw/vendor.qti.hardware.servicetracker@1.0-service: bindService is called for service : com.rmm.test.app/com.urbanairship.job.AndroidJobService and for client system
2020-03-03 15:19:29.330 942-11391/? I//vendor/bin/hw/vendor.qti.hardware.servicetracker@1.0-service: total connections for service : com.rmm.test.app/com.urbanairship.job.AndroidJobServiceare :1
2020-03-03 15:19:29.337 942-11391/? I//vendor/bin/hw/vendor.qti.hardware.servicetracker@1.0-service: startService() is called for servicecom.rmm.test.app/com.urbanairship.job.AndroidJobService
2020-03-03 15:19:29.358 17488-17936/com.rmm.test.app D/ua-test - UALib: EventApiClient - Sending analytics events. Request: com.urbanairship.http.Request@a04ef75 Events: [{"event_id":"978edd93-1bd5-4b68-8989-c81ea0d6c3c3","time":"1583245159.229","data":{"daylight_savings":false,"carrier":"CIC Mobile","package_version":"1.0","connection_type":"wifi","connection_subtype":"","os_version":"10","session_id":"ccc1d8fe-4b0d-4052-ab99-3b6a9217c4f1","time_zone":3600,"lib_version":"12.2.0"},"type":"app_foreground"}]
2020-03-03 15:19:29.412 942-11391/? I//vendor/bin/hw/vendor.qti.hardware.servicetracker@1.0-service: bindService is called for service : com.google.android.gms/.gcm.PushMessagingRegistrarProxy and for client com.rmm.test.app
2020-03-03 15:19:29.412 942-11391/? I//vendor/bin/hw/vendor.qti.hardware.servicetracker@1.0-service: total connections for client : com.rmm.test.appare :5
2020-03-03 15:19:29.428 17488-17819/com.rmm.test.app V/Capacitor/Plugin/PushNotifications: Notifying listeners for event pushNotificationReceived
2020-03-03 15:19:29.433 17488-17488/com.rmm.test.app I/Capacitor/Console: File: http://localhost/static/js/main.b499861c.chunk.js - Line 1 - Msg: Push received: {"id":"0:1583245167760980%6e26ceeef9fd7ecd","data":{"com.urbanairship.push.ALERT":"Hey Android and iOS!!","com.urbanairship.metadata":"eyJ2ZXJzaW9uX2lkIjoxLCJ0aW1lIjoxNTgzMjQ1MTY3NzQxLCJwdXNoX2lkIjoiMWY5MDVlNTAtOWMwMC00NjNhLWE2Y2EtZTQ1NjRjODU2ZjBlIiwiY2FtcGFpZ25zIjp7ImNhdGVnb3JpZXMiOltdfX0=","com.urbanairship.push.PUSH_ID":"fda939e0-5d59-11ea-87c2-02428a0ee1ce","com.urbanairship.push.APID":"429489f9-11ac-4329-a94b-cd5f1a1a5857","com.urbanairship.push.CANONICAL_PUSH_ID":"1f905e50-9c00-463a-a6ca-e4564c856f0e"}}
2020-03-03 15:19:29.437 942-11391/? I//vendor/bin/hw/vendor.qti.hardware.servicetracker@1.0-service: unbindService is called for service : com.google.android.gms/.gcm.PushMessagingRegistrarProxy and for client com.rmm.test.app
2020-03-03 15:19:29.437 942-11391/? I//vendor/bin/hw/vendor.qti.hardware.servicetracker@1.0-service: size of client connections for client: com.rmm.test.appafter removal is 4
2020-03-03 15:19:29.493 17488-17936/com.rmm.test.app D/ua-test - UALib: EventApiClient - Analytics event response: Response{responseBody='', responseHeaders={null=[HTTP/1.1 200 OK], Alt-Svc=[clear], Content-Type=[application/json], Date=[Tue, 03 Mar 2020 14:19:30 GMT], Transfer-Encoding=[chunked], Via=[1.1 google], X-Android-Received-Millis=[1583245169487], X-Android-Response-Source=[NETWORK 200], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1583245169361], X-UA-Max-Batch=[500], X-UA-Max-Total=[5120], X-UA-Max-Wait=[604800000], X-UA-Min-Batch-Interval=[60000]}, status=200, responseMessage='OK', lastModified=0}
2020-03-03 15:19:29.493 17488-17936/com.rmm.test.app D/ua-test - UALib: EventManager - Analytic events uploaded.
2020-03-03 15:19:29.507 942-11391/? I//vendor/bin/hw/vendor.qti.hardware.servicetracker@1.0-service: unbindService is called for service : com.rmm.test.app/com.urbanairship.job.AndroidJobService and for client system
2020-03-03 15:19:29.508 942-11391/? I//vendor/bin/hw/vendor.qti.hardware.servicetracker@1.0-service: size of service connections for service: com.rmm.test.app/com.urbanairship.job.AndroidJobServiceafter removal is 0
2020-03-03 15:19:29.508 942-11391/? I//vendor/bin/hw/vendor.qti.hardware.servicetracker@1.0-service: destroyService is called for service : com.rmm.test.app/com.urbanairship.job.AndroidJobService

If you need more logs, I would gladly help.

rlepinski commented 4 years ago

Could you expand on what you mean by Strangely enough, it works well with FCM directly, using the GCM token from "Android Channel IDs" ? Are you using another library to receive events for those notifications?

How are you listening for the events? It would super helpful if you could provide a sample app that we can use to quickly reproduce the issue.

florianchevallier commented 4 years ago

Hi, thank you for your response.

Here is the example project I'm currently using : https://github.com/florianchevallier/test-ionic-app-notif

You can see here how I did with Capacitor.

Could you expand on what you mean by Strangely enough, it works well with FCM directly, using the GCM token from "Android Channel IDs" ? Are you using another library to receive events for those notifications?

Yes, when I setup the app for UrbanAirship, I've used Firebase to get the the google-services.json.

When I did my tests, a device was registered in UA. I got something like this :

Capture d’écran 2020-03-03 à 20 15 26

I went to firebase, and sent a notification from the firebase console here, using the GCM token :

Capture d’écran 2020-03-03 à 20 18 46

And got the notification in background.

The payload from firebase was like this :

{
  "id": "0:1583243373187715%6e26ceee6e26ceee",
  "data": {},
  "title": "aze",
  "body": "aze"
}

While the one from UA looks like this :

{
  "id": "0:1583243590511608%6e26ceeef9fd7ecd",
  "data": {
    "com.urbanairship.push.ALERT": "Hello Android!",
    "com.urbanairship.metadata": "eyJ2ZXJzaW9uX2lkIjoxLCJ0aW1lIjoxNTgzMjQzNTkwNDU4LCJwdXNoX2lkIjoiYWE4Y2Y2MmUtMDBiOC00ODA1LTk3NDctNmU4Y2JkMzUxYTM3IiwiY2FtcGFpZ25zIjp7ImNhdGVnb3JpZXMiOltdfX0=",
    "com.urbanairship.push.PUSH_ID": "5186c9a6-5d56-11ea-a992-024229971edf",
    "com.urbanairship.title": "Insert title here!",
    "com.urbanairship.push.APID": "429489f9-11ac-4329-a94b-cd5f1a1a5857",
    "com.urbanairship.push.CANONICAL_PUSH_ID": "aa8cf62e-00b8-4805-9747-6e8cbd351a37"
  }
}
rlepinski commented 4 years ago

The notification is not displaying or is the app not able to get a callback when the push is received?

florianchevallier commented 4 years ago

The notification is not displaying at all (with UA, but it's displaying when sent from the firebase console)

rlepinski commented 4 years ago

@florianchevallier Could you post your merged manifest from app/build/intermediates/merged_manifests/debug/AndroidManifest.xml ?

florianchevallier commented 4 years ago

yes ! It looks like this :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.rmm.test.app"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="21"
        android:targetSdkVersion="28" />

    <!-- Permissions -->

    <uses-permission android:name="android.permission.INTERNET" />
    <!-- Camera, Photos, input file -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <!-- Geolocation API -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <uses-feature android:name="android.hardware.location.gps" />
    <!-- Network API -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- Navigator.getUserMedia -->
    <!-- Video -->
    <uses-permission android:name="android.permission.CAMERA" />
    <!-- Audio -->
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

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

    <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Required by older versions of Google Play services to create IID tokens -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.VIBRATE" />

    <application
        android:allowBackup="true"
        android:appComponentFactory="androidx.core.app.CoreComponentFactory"
        android:debuggable="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:testOnly="true"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.rmm.test.app.MainActivity"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
            android:label="@string/title_activity_main"
            android:launchMode="singleTask"
            android:theme="@style/AppTheme.NoActionBarLaunch" >
            <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:scheme="@string/custom_url_scheme" />
            </intent-filter>
        </activity>

        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="com.rmm.test.app.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true" >
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths" />
        </provider>

        <meta-data
            android:name="com.urbanairship.cordova.version"
            android:value="10.1.0" />
        <meta-data
            android:name="com.urbanairship.autopilot"
            android:value="com.urbanairship.cordova.CordovaAutopilot" />
        <meta-data
            android:name="com.urbanairship.webview.ENABLE_LOCAL_STORAGE"
            android:value="true" />

        <activity
            android:name="com.urbanairship.cordova.CustomMessageActivity"
            android:exported="false"
            android:theme="@android:style/Theme.DeviceDefault.Light" >
            <intent-filter>
                <action android:name="com.urbanairship.VIEW_RICH_PUSH_MESSAGE" />

                <data android:scheme="message" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.urbanairship.cordova.CustomMessageCenterActivity"
            android:exported="false"
            android:launchMode="singleTask"
            android:theme="@android:style/Theme.DeviceDefault.Light" >
            <intent-filter>
                <action android:name="com.urbanairship.VIEW_RICH_PUSH_INBOX" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <service
            android:name="com.getcapacitor.plugin.background.BackgroundTaskService"
            android:exported="false" />

        <receiver android:name="com.getcapacitor.plugin.notification.TimedNotificationPublisher" />
        <receiver android:name="com.getcapacitor.plugin.notification.NotificationDismissReceiver" />

        <meta-data
            android:name="firebase_messaging_auto_init_enabled"
            android:value="false" />

        <service
            android:name="com.getcapacitor.CapacitorFirebaseMessagingService"
            android:stopWithTask="false" >
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service> <!-- Firebase checks permissions at runtime -->
        <service android:name="com.urbanairship.push.fcm.AirshipFirebaseMessagingService" >
            <intent-filter android:priority="-1" >
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
        <!--
             FirebaseMessagingService performs security checks at runtime,
             but set to not exported to explicitly avoid allowing another app to call it.
        -->
        <service
            android:name="com.google.firebase.messaging.FirebaseMessagingService"
            android:exported="false" >
            <intent-filter android:priority="-500" >
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
        <service
            android:name="com.google.firebase.components.ComponentDiscoveryService"
            android:directBootAware="true"
            android:exported="false" >
            <meta-data
                android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
        </service>

        <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" />
            </intent-filter>
        </receiver>

        <activity
            android:name="com.google.android.gms.common.api.GoogleApiActivity"
            android:exported="false"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />
        <activity
            android:name="com.urbanairship.iam.html.HtmlActivity"
            android:exported="false"
            android:theme="@style/UrbanAirship.InAppHtml.Activity" >
            <meta-data
                android:name="com.urbanairship.push.iam.EXCLUDE_FROM_AUTO_SHOW"
                android:value="true" />
        </activity>
        <activity
            android:name="com.urbanairship.iam.fullscreen.FullScreenActivity"
            android:exported="false"
            android:theme="@style/UrbanAirship.InAppFullscreen.Activity" >
            <meta-data
                android:name="com.urbanairship.push.iam.EXCLUDE_FROM_AUTO_SHOW"
                android:value="true" />
        </activity>
        <activity
            android:name="com.urbanairship.iam.modal.ModalActivity"
            android:exported="false"
            android:theme="@style/UrbanAirship.InAppModal.Activity" >
            <meta-data
                android:name="com.urbanairship.push.iam.EXCLUDE_FROM_AUTO_SHOW"
                android:value="true" />
        </activity>
        <activity
            android:name="com.urbanairship.push.NotificationProxyActivity"
            android:exported="false"
            android:taskAffinity="com.urbanairship.push.NotificationProxyActivity"
            android:theme="@android:style/Theme.NoDisplay" />
        <activity
            android:name="com.urbanairship.messagecenter.MessageActivity"
            android:exported="false" />
        <activity
            android:name="com.urbanairship.messagecenter.MessageCenterActivity"
            android:exported="false"
            android:label="@string/ua_message_center_title" />
        <activity
            android:name="com.urbanairship.util.HelperActivity"
            android:exported="false"
            android:theme="@style/UrbanAirship.HelperActivity" >
            <meta-data
                android:name="com.urbanairship.push.iam.EXCLUDE_FROM_AUTO_SHOW"
                android:value="true" />
        </activity>
        <activity
            android:name="com.urbanairship.google.PlayServicesErrorActivity"
            android:exported="false"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" >
            <meta-data
                android:name="com.urbanairship.push.iam.EXCLUDE_FROM_AUTO_SHOW"
                android:value="true" />
        </activity>
        <activity
            android:name="com.urbanairship.actions.RateAppActivity"
            android:exported="false"
            android:theme="@style/UrbanAirship.RateAppActivity" >
            <meta-data
                android:name="com.urbanairship.push.iam.EXCLUDE_FROM_AUTO_SHOW"
                android:value="true" />

            <intent-filter>
                <action android:name="com.urbanairship.actions.SHOW_RATE_APP_INTENT_ACTION" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.urbanairship.ChannelCaptureActivity"
            android:exported="false" >
            <meta-data
                android:name="com.urbanairship.push.iam.EXCLUDE_FROM_AUTO_SHOW"
                android:value="true" />
        </activity>

        <service android:name="com.urbanairship.job.AirshipService" />

        <receiver
            android:name="com.urbanairship.location.LocationReceiver"
            android:exported="false" />

        <service
            android:name="com.urbanairship.job.AndroidJobService"
            android:permission="android.permission.BIND_JOB_SERVICE" />

        <receiver
            android:name="com.urbanairship.push.NotificationProxyReceiver"
            android:exported="false" >
            <intent-filter android:priority="-999" >
                <action android:name="com.urbanairship.push.OPENED" />

                <category android:name="com.rmm.test.app" />
            </intent-filter>
        </receiver>
        <receiver
            android:name="com.urbanairship.locale.LocaleChangeReceiver"
            android:exported="false" >
            <intent-filter>
                <action android:name="android.intent.action.LOCALE_CHANGED" />
            </intent-filter>
        </receiver>

        <provider
            android:name="com.urbanairship.UrbanAirshipProvider"
            android:authorities="com.rmm.test.app.urbanairship.provider"
            android:exported="false" />
        <provider
            android:name="com.google.firebase.provider.FirebaseInitProvider"
            android:authorities="com.rmm.test.app.firebaseinitprovider"
            android:exported="false"
            android:initOrder="100" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
    </application>

</manifest>
rlepinski commented 4 years ago

Looks like capacitor is preventing the Airship SDK from receiving any push events:

        <service
            android:name="com.getcapacitor.CapacitorFirebaseMessagingService"
            android:stopWithTask="false" >
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service> <!-- Firebase checks permissions at runtime -->
        <service android:name="com.urbanairship.push.fcm.AirshipFirebaseMessagingService" >
            <intent-filter android:priority="-1" >
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

Only the highest priority service is able to receive the com.google.firebase.MESSAGING_EVENT. You can try adding our service to your manifest to make it higher priority, but it will prevent capacitor from being able to process the notification:

        <service android:name="com.urbanairship.push.fcm.AirshipFirebaseMessagingService" >
            <intent-filter android:priority="10" >
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

To keep both working, you will need to create your own messaging service that notifies both capacitor and the Airship SDK. Example:

package com.rmm.test.app;

import com.getcapacitor.CapacitorFirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.urbanairship.push.fcm.AirshipFirebaseIntegration;

public class PushService extends CapacitorFirebaseMessagingService {

    @Override
    public void onNewToken(String newToken) {
        super.onNewToken(newToken);
        AirshipFirebaseIntegration.processNewToken(getApplicationContext());
    }

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        AirshipFirebaseIntegration.processMessageSync(getApplicationContext(), remoteMessage);
    }
}

Then register that service:

        <service android:name="com.rmm.test.app.PushService" >
            <intent-filter android:priority="10" >
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

Our SDK currently posts the notification if its in the foreground or background, so it's actually broken in both cases. That foreground event you are receiving is from the Capacitor listener not ours.

florianchevallier commented 4 years ago

Hey, thank you for you complete answer.

It seems a LOT more complicated than what I've anticipated. Given that this file is handled by capacitor, it will likely change on each update / sync.

I'll open an issue in Capacitor to see if they can handle this case.

Thank you

florianchevallier commented 4 years ago

Alright, it works for me. Thank you for your support.

rlepinski commented 4 years ago

The methods you are overriding are the Firebase service methods, so as long as capacitor does not mark them as final you should be fine. Its more of a firebase limitation than a capacitor issue. If you dont care about capacitor working with fcm, you could just remove the service using manifest merge tools - http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger

florianchevallier commented 2 years ago

hey @rlepinski !

After a year and a half, the API has changed and the code you sent is not working anymore


package rmm.transmitter.app;

import com.getcapacitor.CapacitorFirebaseMessagingService; // <--- this doesn't exist anymore
import com.google.firebase.messaging.RemoteMessage;
import com.urbanairship.push.fcm.AirshipFirebaseIntegration;

public class PushService extends CapacitorFirebaseMessagingService {

    @Override
    public void onNewToken(String newToken) {
        super.onNewToken(newToken);
        AirshipFirebaseIntegration.processNewToken(getApplicationContext());
    }

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        AirshipFirebaseIntegration.processMessageSync(getApplicationContext(), remoteMessage);
    }
}

Do you know how I could resolve this ?

Many thanks

florianchevallier commented 2 years ago

For anyone (maybe me in the future) who needs the new PushService, here it is (working with cordova 3 & firebase 21)


package rmm.transmitter.app;

import androidx.annotation.NonNull;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.urbanairship.push.fcm.AirshipFirebaseIntegration;

public class PushService extends FirebaseMessagingService {

    @Override
    public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        AirshipFirebaseIntegration.processMessageSync(getApplicationContext(), remoteMessage);
    }

    @Override
    public void onNewToken(@NonNull String s) {
        super.onNewToken(s);
        AirshipFirebaseIntegration.processNewToken(getApplicationContext(), s);
    }
}
matthew1000 commented 1 year ago

In case this helps anyone in the future, I addressed this issue by ensuring that @capacitor/push-notifications wasn't installed - only @ionic-native/urbanairship.