havesource / cordova-plugin-push

Register and receive push notifications
MIT License
144 stars 276 forks source link

Error with icons #191

Closed albertleao closed 1 year ago

albertleao commented 1 year ago

Bug Report

Push notification has been working for a while but background notifications have stopped. Foreground notifications working as expected.

I have <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_notification" />

And my res/drawable/ic_notification folder has icons generated by android studio

Expected Behaviour

Notification when the app is not in the foreground pops a notification in the status bar and android notification

Actual Behaviour

No notification but the following error in logs

Steps to Reproduce

Push notification when app is in background

Platform and Version (eg. Android 12.0)

Android 12

(Android) Device Vendor (e.g. Samsung, HTC, Sony...)

Samsung

cordova info Printout

Cordova Packages:

cli: 11.0.0
    common: 4.0.2
    create: 4.0.0
    lib: 11.0.0
        common: 4.0.2
        fetch: 3.0.1
        serve: 4.0.0

Project Installed Platforms:

android: 10.1.2
ios: 6.2.0

Project Installed Plugins:

@havesource/cordova-plugin-push: 3.0.1
cordova-clipboard: 1.3.0
cordova-plugin-app-version: 0.1.12
cordova-plugin-camera: 6.0.0
cordova-plugin-device: 2.0.3
cordova-plugin-dialogs: 2.0.2
cordova-plugin-exclude-files: 1.0.1
cordova-plugin-file-transfer-latest: 2.0.2-dev
cordova-plugin-file: 6.0.2
cordova-plugin-inappbrowser: 5.0.0
cordova-plugin-keyboard: 1.2.0
cordova-plugin-network-information: 3.0.0
cordova-plugin-purchase: 11.0.0
cordova-plugin-splashscreen: 6.0.0
cordova-plugin-statusbar: 2.4.3
cordova-plugin-vibration: 3.1.1

Environment:

OS: macOS Monterey 12.4 (21F79) (darwin 21.5.0) x64
Node: v14.16.1
npm: 6.14.12

android Environment:

android:

ERROR: Command failed with ENOENT: avdmanager list target spawn avdmanager ENOENT

ios Environment:

xcodebuild:

Xcode 13.4 Build version 13F17a

Project Setting Files:

config.xml:

<?xml version='1.0' encoding='utf-8'?>

REDACTED REDACTED needs camera access to take picture and upload to your account. REDACTED needs access to your photo library to upload desired photos to your account. REDACTED needs access to your photo library to save photos.
package.json:

--- Start of Cordova JSON Snippet --- { "plugins": { "cordova-plugin-statusbar": {}, "cordova-plugin-vibration": {}, "cordova-plugin-splashscreen": {}, "cordova-plugin-file-transfer-latest": {}, "cordova-plugin-file": {}, "cordova-plugin-keyboard": {}, "cordova-plugin-camera": { "ANDROIDX_CORE_VERSION": "1.6.+" }, "cordova-plugin-app-version": {}, "cordova-plugin-purchase": {}, "cordova-plugin-dialogs": {}, "cordova-plugin-exclude-files": {}, "cordova-plugin-device": {}, "cordova-clipboard": {}, "cordova-plugin-inappbrowser": {}, "@havesource/cordova-plugin-push": { "ANDROIDX_CORE_VERSION": "1.6.+", "FCM_VERSION": "18.+", "IOS_FIREBASE_MESSAGING_VERSION": "~> 6.32.2" } }, "platforms": [ "ios", "android" ] }

Sample Push Data Payload

{
  "GCM": "{ \"data\": { \"message\": \"Sample message for Android endpoints\" } }"
}

Logs taken while reproducing problem


E/AndroidRuntime: FATAL EXCEPTION: Firebase-FCMService
    Process: com.app.test, PID: 5496
    java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(channel=PushPluginChannel shortcut=null contentView=null vibrate=null sound=null tick defaults=0x0 flags=0x10 color=0xff26315f vis=PRIVATE semFlags=0x0 semPriority=0 semMissedCount=0)
        at android.app.NotificationManager.fixNotification(NotificationManager.java:718)
        at android.app.NotificationManager.notifyAsUser(NotificationManager.java:697)
        at android.app.NotificationManager.notify(NotificationManager.java:631)
        at com.adobe.phonegap.push.FCMService.createNotification(FCMService.kt:573)
        at com.adobe.phonegap.push.FCMService.showNotificationIfPossible(FCMService.kt:411)
        at com.adobe.phonegap.push.FCMService.onMessageReceived(FCMService.kt:136)
        at com.google.firebase.messaging.FirebaseMessagingService.zzd(Unknown Source:67)
        at com.google.firebase.iid.zzf.run(Unknown Source:4)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:6)
        at java.lang.Thread.run(Thread.java:920)
mackenrou commented 1 year ago

Hello! I have the same problem. How did you fix this?

dannygunawan commented 1 year ago

i have the same problem

cmartin81 commented 1 year ago

I also have the same problem. Any update on this?

nguyendinhdoan commented 1 year ago

Any update? I have the same issue.

dannygunawan commented 1 year ago

In my case, the problem was because I set custom icon options on PushNotification.init()

PushNotification.init(
            {
                "android": {
                    icon: "notification"
                }
            }
        );

There 2 solutions for this case: remove the custom icon options from the function above or open the project in Android Studio and then create new icon assets from Image Assets Studio.