havesource / cordova-plugin-push

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

Cannot Trigger Critical Alerts #86

Open ggiordan opened 3 years ago

ggiordan commented 3 years ago

Bug Report

I cannot get the critical alerts confirmation to trigger. My app does have critical alerts in the provisioning profile. I am getting a build warning about the entitlements file not matching the provisioning profile.

Expected Behaviour

When .init is called for the first time, Critical alerts dialog is presented to user

Actual Behaviour

User gets normal allow push notifications dialog

Reproduce Scenario / Build Warning

Provisioning profile "XXXX-CriticalAlerts" for "XXXX" contains entitlements that aren't in the entitlements file: com.apple.developer.usernotifications.critical-alerts. To use these entitlements, add them to your entitlements file. Otherwise, remove unused entitlements from your provisioning profile.

Platform and Version

IOS / XCODE 12.4

cordova info Printout

Cordova Packages:

cli: 10.0.0
    common: 4.0.2
    create: 3.0.0
    lib: 10.0.0
        common: 4.0.2
        fetch: 3.0.0
        serve: 4.0.0

Project Installed Platforms:

ios: 6.1.1

Project Installed Plugins:

@havesource/cordova-plugin-push: 2.0.0
com.googlemaps.ios: 3.9.0
cordova-plugin-appavailability: 0.4.2
cordova-plugin-device: 2.0.3
cordova-plugin-dialogs: 2.0.2
cordova-plugin-file: 6.0.2
cordova-plugin-geolocation: 4.1.0
cordova-plugin-globalization: 1.11.0
cordova-plugin-googlemaps: 2.7.1
cordova-plugin-inappbrowser: 4.1.0
cordova-plugin-insomnia: 4.3.0
cordova-plugin-ios-non-exempt-encryption: 1.0.0
cordova-plugin-media: 5.0.3
cordova-plugin-network-information: 2.0.2
cordova-plugin-sim: 1.3.3
cordova-plugin-splashscreen: 6.0.0
cordova-plugin-statusbar: 2.4.3
cordova-plugin-whitelist: 1.3.4
cordova-plugin-wkwebview-file-xhr: 3.0.0

Environment:

OS: macOS Catalina 10.15.7 (19H524) (darwin 19.6.0) x64
Node: v10.15.1
npm: 6.14.9

ios Environment:

xcodebuild:

Xcode 12.4 Build version 12D4e

Project Setting Files:

config.xml:

<?xml version='1.0' encoding='utf-8'?> <widget id="XXXXXXX" version="0.0.0.0" defaultlocale="en-US" android-packageName="XXXXXXX" android-versionCode="000000000" ios-CFBundleIdentifier="XXXXXX" windows-packageVersion="000000" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:vs="http://schemas.microsoft.com/appx/2014/htmlapps">

XXXXXXXX
<content src="index.html" />
<access origin="*" />
<preference name="SplashScreen" value="screen" />
<preference name="windows-target-version" value="10.0" />
<preference name="WindowsToastCapable" value="true" />

<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
    <allow-intent href="market:*" />
    <allow-navigation href="*" />
    <allow-intent href="*" />
</platform>
<platform name="android">
    <resource-file src="google-services.json" target="app/google-services.json" />
</platform>
<preference name="webviewbounce" value="false" />
<preference name="DisallowOverscroll" value="true" />
<preference name="Fullscreen" value="false" />
<preference name="BackupWebStorage" value="cloud" />
<preference name="android-minSdkVersion" value="22" />
<preference name="android-targetSdkVersion" value="29" />
<preference name="deployment-target" value="11.0" />

package.json:

--- Start of Cordova JSON Snippet --- { "platforms": [ "android", "windows", "ios" ], "plugins": { "cordova-plugin-appavailability": {}, "cordova-plugin-file": {}, "cordova-plugin-globalization": {}, "cordova-plugin-insomnia": {}, "cordova-plugin-ios-non-exempt-encryption": {}, "cordova-plugin-sim": {}, "cordova-plugin-dialogs": {}, "cordova-plugin-device": {}, "cordova-plugin-inappbrowser": {}, "cordova-plugin-media": { "KEEP_AVAUDIOSESSION_ALWAYS_ACTIVE": "NO" }, "cordova-plugin-network-information": {}, "cordova-plugin-splashscreen": {}, "cordova-plugin-statusbar": {}, "cordova-plugin-geolocation": { "GPS_REQUIRED": "true", "LOCATION_ALWAYS_USAGE_DESCRIPTION": "This app wants to get your location always, even when this app runs in background." }, "cordova-plugin-googlemaps": { "PLAY_SERVICES_VERSION": "16.0.1", "ANDROID_SUPPORT_V4_VERSION": "27.+", "GPS_REQUIRED": "true", "LOCATION_WHEN_IN_USE_DESCRIPTION": "This app wants to get your location while this app runs only.", "LOCATION_ALWAYS_USAGE_DESCRIPTION": "This app wants to get your location always, even this app runs in background." }, "cordova-plugin-wkwebview-file-xhr": {}, "cordova-plugin-whitelist": {}, "@havesource/cordova-plugin-push": { "IOS_FIREBASE_MESSAGING_VERSION": "~> 6.32.2" } } } --- End of Cordova JSON Snippet ---

ggiordan commented 3 years ago

I got it to work, the Entitlements-Release.plist and Entitlements-Debug.plist filed need to have the following entry: <key>com.apple.developer.usernotifications.critical-alerts</key> <true/>

The next problem is getting that entry added to the file. I cannot seem to get the config-file section to work correctly in the config.xml Ideally the we could set a flag and the plugin installer would make the change.

Any one else able to get this to work?

weichen35 commented 2 years ago

I'm using Pushwoosh and I'm encountering the same issue. I can't find how Cordova can trigger a Critical Alert dialog for the user to receive critical alerts.