@havesource/cordova-plugin-push

I think I’m stuck.

Has anyone else gotten @havesource/cordova-plugin-push to build since the Android App Store requirement change to SDK Version 31 last November?

I need to patch a bug in our existing application, but can only get the push plugin to work with the following, which Google is no longer permitting:

<engine name="android" spec="10.1.2" />
<preference name="android-targetSdkVersion" value="30" />

Following along in the repo’s issues list, the maintainer seems to have fixed the issue with Android 12 (SDK Version 31) nearly a year ago, but has left it as a dev release for the time being (4.0.0.dev.0). Possibly due to potential issues this update may or may not be having with iOS.

The Voltbuilder upload tool does not allow for plugin versions of this kind:

<plugin name="@havesource/cordova-plugin-push" spec="4.0.0.dev.0">

UserError: Error: Plugin '@havesource/cordova-plugin-push' has invalid spec: '4.0.0.dev.0'.
Plugin specs should be in the form '1.2.3'. They should not include pathnames or URLs. 

Has anyone else gotten this to work? Or does anyone have recommendations for a different push notification plugin (Android & iOS) that has a better track record for stability. This one has had me a bit worried ever since it was forked from the now obsolete phonegap-plugin-push.

you can use the “cordova-plugin-firebasex” plugin
I compiled just a day ago without problems and the plugin works fine.
Below is an excerpt of my config.xml:

            ...
<preference name="android-minSdkVersion" value="22" />
<preference name="android-compileSdkVersion" value="31" />
<preference name="android-targetSdkVersion" value="31" />
<preference name="android-build-tool" value="gradle" />
<platform name="android">
    <engine name="android" spec="11.0.0" />
    <preference name="AndroidInsecureFileModeEnabled" value="true" />
   <preference name="AndroidXEnabled" value="true" />                       
    <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
        <application android:requestLegacyExternalStorage="true" android:usesCleartextTraffic="true" />
    </edit-config>
    <config-file parent="/manifest" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android">
        <uses-permission android:name="android.permission.FLAG_GRANT_READ_URI_PERMISSION" />
        <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    </config-file>
    ...
<plugin name="cordova-plugin-firebasex" source="npm" spec="16.0.0" >
    <variable name="ANDROID_FIREBASE_CONFIG_FILEPATH" value="google-services.json" /> 
   <variable name="IOS_FIREBASE_CONFIG_FILEPATH" value="GoogleService-Info.plist" />
    <variable name="IOS_STRIP_DEBUG" value="true" />                          
    <variable name="FIREBASE_ANALYTICS_COLLECTION_ENABLED" value="false" />
    <variable name="FIREBASE_PERFORMANCE_COLLECTION_ENABLED" value="false" />
    <variable name="FIREBASE_CRASHLYTICS_COLLECTION_ENABLED" value="false" />
</plugin>
<!-- plugins to exclude when compiling for Windows/ios: -->  
<plugin name="cordova-plugin-android-permissions" source="npm" spec="1.1.4" />
<plugin name="cordova-plugin-androidx-adapter" source="npm" spec="1.1.3" />

There’s actually an error in your version specification. Notice that the version is 4.0.0-dev.0: https://www.npmjs.com/package/@havesource/cordova-plugin-push/v/4.0.0-dev.0

If you correct that, you should be able to use your preferred version of the plugin with VoltBuilder.

I make it work using the development version of the plugin that already has a fix for this bug, whit the @dev flag on the plugin tag, like:

<plugin name="@havesource/cordova-plugin-push@dev" />

Hi,

As suggested here, for Android 12 compatibility (API level 31), I’m using:

<plugin name="@havesource/cordova-plugin-push@dev" source="npm" />

Everything was working fine until few days ago. Now I’m getting this error when building:

Execution failed for task ':app:compileReleaseKotlin'. Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
Log: https://apps.volt.build/4cbb6db9-6b02-4482-865f-c03b913d425c/voltbuilder.log

The latest plugin update was released 4 months ago. Has something changed on VoltBuild side?

There’s some workaround in config.xml that I can use?
I’ve tried the plugin cordova-android-play-services-gradle-release with no luck.

Thanks in advance
D.

Solved.
I added these lines to my config.xml and build succeeded:

<preference name="GradlePluginKotlinEnabled" value="true" />
<preference name="GradlePluginKotlinVersion" value="1.7.10" />

Hope it helps
D.

3 Likes

Following up on this:

I tried using: <plugin name="@havesource/cordova-plugin-push@dev" />, but ran into some issues with it. This was before the Gradle/Kotlin settings were mentioned above, so I did not try those.

I ended up switching over to cordova-plugin-firebasex and have everything working now. For anyone else reading this, that involved:

  • Changing the JS handling the plugin. This was a bit tricky, as not having the function parameters exactly correct would crash iOS, but not Android.
  • Changing the push notification payload server side. The two plugins did not seem to use compatible payloads.

Also of note:

  • I got Crashlytics for free through the Firebase console
  • The app bundle size increased a fair amount

Good afternoon, does the plugin work with ios? or only on android?

@venazco - you can find the documentation in npmjs.com.

It works on Android and iOS. And you can send the iOS push notifications through either FCM or APNS.