Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications not being receieved on Android since 3.0.0 update #157

Open
asgeo1 opened this issue Jan 11, 2022 · 2 comments
Open

Notifications not being receieved on Android since 3.0.0 update #157

asgeo1 opened this issue Jan 11, 2022 · 2 comments

Comments

@asgeo1
Copy link

asgeo1 commented Jan 11, 2022

Bug Report

Did anything change with the 3.0.0 update, that would prevent push notifications being received in an app that worked with an earlier version?

I've upgraded our push plugin from v2.3.0 on the original phonegap/phonegap-plugin-push repo, to 3.0.0 in this repo, and found that I'm no longer able to receive push notifications on Android.

I'm not talking about the app not handing the push notification correctly. I mean it is not received at all. Nothing in the system notification tray, no noise, nothing.

And yes, the app does appear to correctly "register" for push, and I get a token, and I'm using the correct token to send the push notification and all that.

I did a Git bisect between 87a8132 and a1df480, and found that 1568abb was the commit where the issue first started happening.

Expected Behaviour

Triggering a basic push notification to the device token, should result in some kind of notification being received by my device.

Actual Behaviour

Nothing is received on the device, despite sending the push notification to the correct token, and no errors from FCM in the process.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Android 10

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

Google

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.1
    ios: 6.2.0

Project Installed Plugins:

    com.googlemaps.ios: 3.9.0
    cordova-androidx-build: 1.0.4
    cordova-clipboard: 1.3.0
    cordova-plugin-add-swift-support: 2.0.2
    cordova-plugin-app-version: 0.1.9
    cordova-plugin-appavailability: 0.4.2
    cordova-plugin-chooser: 1.3.1
    cordova-plugin-customurlscheme: 4.4.0
    cordova-plugin-device: 2.0.3
    cordova-plugin-directions: 0.4.4
    cordova-plugin-file-opener2: 2.2.1
    cordova-plugin-file-transfer: 2.0.0-dev
    cordova-plugin-file: 6.0.2
    cordova-plugin-geolocation: 4.0.1
    cordova-plugin-googlemaps: 2.8.0-20200709-2008
    cordova-plugin-inappbrowser: 4.0.0
    cordova-plugin-intercom: 10.2.0
    cordova-plugin-ionic-keyboard: 2.2.0
    cordova-plugin-ionic-webview: 5.0.0
    cordova-plugin-splashscreen: 6.0.0
    cordova-plugin-statusbar: 2.4.3
    cordova-plugin-x-socialsharing: 5.6.0
    cordova-sqlite-storage: 3.4.0
    cordova-support-google-services: 1.3.2
    cordova-universal-links-plugin: 1.2.1
    es6-promise-plugin: 4.2.2
    phonegap-plugin-multidex: 1.0.0
    phonegap-plugin-push: 2.3.0
    sentry-cordova: 1.0.0-rc.0

Environment:

    OS: macOS Monterey 12.0.1 (21A559) (darwin 21.1.0) arm64
    Node: v16.7.0
    npm: 8.1.3

android Environment:

    android:
Available Android targets:==============] 100% Fetch remote repository...       
----------
id: 1 or "android-30"
     Name: Android API 30
     Type: Platform
     API level: 30
     Revision: 3
----------
id: 2 or "android-31"
     Name: Android API 31
     Type: Platform
     API level: 31
     Revision: 1


ios Environment:

    xcodebuild:
Xcode 13.2.1
Build version 13C100


Project Setting Files:

    config.xml:
<?xml version="1.0" encoding="utf-8"?>
<widget android-versionCode="332009" id="xxx.xxxx.xxx" version="3.32.9" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>XXXX</name>
    <description>
        XXXX application
    </description>
    <author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author>
    <content src="index.html"/>
    <access origin="*"/>
    <preference name="DisallowOverscroll" value="true"/>
    <preference name="ScrollEnabled" value="false"/>
    <preference name="SplashMaintainAspectRatio" value="true"/>
    <preference name="SplashShowOnlyFirstTime" value="false"/>
    <preference name="SplashScreen" value="screen"/>
    <preference name="AutoHideSplashScreen" value="false"/>
    <preference name="FadeSplashScreenDuration" value="0"/>
    <preference name="SplashScreenDelay" value="0"/>
    <allow-intent href="http://*/*"/>
    <allow-intent href="https://*/*"/>
    <allow-intent href="tel:*"/>
    <allow-intent href="sms:*"/>
    <allow-intent href="mailto:*"/>
    <allow-intent href="geo:*"/>
    <allow-intent href="xxxx:*"/>
    <platform name="android">
        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
            <application android:networkSecurityConfig="@xml/network_security_config"/>
            <application android:usesCleartextTraffic="true"/>
            <application android:largeHeap="true"/>
        </edit-config>
        <resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml"/>
        <resource-file src="build-extras.gradle" target="app/build-extras.gradle"/>
        <resource-file src="google-services.json.prod" target="app/google-services.json"/>
        <hook src="scripts/add-env-to-config-android.js" type="before_prepare"/>
        <hook src="scripts/android-res-hook.js" type="before_build"/>
        <allow-intent href="market:*"/>
        <preference name="intercom-android-push-type" value="fcm-without-build-plugin"/>
        <preference name="loadUrlTimeoutValue" value="70000"/>
        <preference name="android-minSdkVersion" value="22"/>
        <preference name="android-targetSdkVersion" value="30"/>
        <preference name="AndroidPersistentFileLocation" value="Compatibility"/>
        <preference name="AndroidXEnabled" value="true"/>
        <preference name="AndroidLaunchMode" value="singleTask"/>
        <preference name="AndroidInsecureFileModeEnabled" value="true"/>
    </platform>
    <platform name="ios">
        <preference name="BackupWebStorage" value="none"/>
        <preference name="StatusBarOverlaysWebView" value="false"/>
        <preference name="KeyboardDisplayRequiresUserAction" value="false"/>
        <allow-intent href="itms:*"/>
        <allow-intent href="itms-apps:*"/>
        <config-file target="*-Info.plist" parent="ITSAppUsesNonExemptEncryption">
            <false/>
        </config-file>
    </platform>
</widget>

    package.json:
--- Start of Cordova JSON Snippet ---
{
  "plugins": {
    "cordova-plugin-file-opener2": {
      "ANDROID_SUPPORT_V4_VERSION": "28.+"
    },
    "cordova-plugin-app-version": {},
    "cordova-sqlite-storage": {},
    "cordova-plugin-appavailability": {},
    "cordova-clipboard": {},
    "cordova-plugin-x-socialsharing": {
      "PHOTO_LIBRARY_USAGE_DESCRIPTION": "We allow you to send us photos via our in-app messenger",
      "PHOTO_LIBRARY_ADD_USAGE_DESCRIPTION": "We allow you to save photos we may send you via our in-app messenger",
      "ANDROID_SUPPORT_V4_VERSION": "28.+"
    },
    "cordova-plugin-statusbar": {},
    "cordova-plugin-device": {},
    "cordova-plugin-ionic-keyboard": {},
    "cordova-universal-links-plugin": {},
    "cordova-plugin-directions": {},
    "cordova-plugin-geolocation": {},
    "cordova-plugin-customurlscheme": {
      "URL_SCHEME": "xxxx",
      "ANDROID_SCHEME": " ",
      "ANDROID_HOST": " ",
      "ANDROID_PATHPREFIX": "/"
    },
    "cordova-plugin-ionic-webview": {},
    "cordova-plugin-inappbrowser": {},
    "cordova-plugin-googlemaps": {
      "LOCATION_WHEN_IN_USE_DESCRIPTION": "XXX uses your location to display mapping directions",
      "LOCATION_ALWAYS_USAGE_DESCRIPTION": "XXX uses your location to display mapping directions"
    },
    "cordova-androidx-build": {},
    "cordova-plugin-splashscreen": {},
    "sentry-cordova": {
      "SENTRY_ANDROID_SDK_VERSION": "4.1.0"
    },
    "cordova-plugin-chooser": {},
    "cordova-plugin-file": {},
    "cordova-plugin-file-transfer": {},
    "cordova-plugin-intercom": {},
    "phonegap-plugin-push": {
      "ANDROID_SUPPORT_V13_VERSION": "27.+",
      "FCM_VERSION": "17.0.+"
    }
  },
  "platforms": [
    "ios",
    "android"
  ]
}
--- End of Cordova JSON Snippet ---

Sample Push Data Payload

{
 "registration_ids" : ["xxxxxx"],
 "data": {
	"title": "XXXX Test 2",
    "message" : "This is a test message from XXXX",
	"sound": "1",
	"vibrate": "1",
	"priority": 2
  } 
}

Sample Code that illustrates the problem

Not really doing anything other than calling

    const config: PushOptions = {
      ios: {
        badge: 'true',
        sound: 'true',
        alert: 'true',
        clearBadge: 'true'
      },
      android: {
        icon: 'push_icon_blue'
      }
    }

    this.pushInstance = this.push.init(config)

    // NOTE: Intercom can cause this to be called a 2nd time...
    await this.pushInstance.on('registration').subscribe(async registration => {
       ... do something with the token here...
    })

   this is using `@ionic-native/push/ngx` rather than this plugins JS methods directly, however, it's the same thing end of day I would think, one just calls the other.

Logs taken while reproducing problem

@pschinis
Copy link

pschinis commented Mar 3, 2022

Have you had any luck solving this? I'm noticing it too but only on some Android devices. It works on my Moto G Play 2021 but not on my Galaxy Note 20 Ultra.

@eradin
Copy link

eradin commented Aug 14, 2022

It's now August and I just upgraded to the V3 plugin from the old phonegap 2.3 plugin. 2.3 was working perfectly on both Android and IOS for years. With the 3.0 plugin installed, I'm seeing the same behavior as documented here. I can register fine, I see the token in my DB but the notification event is never called in any circumstance (foreground, background etc.). I am also using FCM for IOS and it appears to be working fine. I am testing on a Galaxy S21 Android 12 and I have the Android X adapter installed too. Build was done with Cordova Android 9.1, IOS 6.2. I'll probably revert back to Phonegap 2.3 until this is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants