diff --git a/README.md b/README.md
index 427eda4..ed723a2 100644
--- a/README.md
+++ b/README.md
@@ -29,11 +29,11 @@
cordova plugin add https://github.com/aerogear/aerogear-cordova-push.git#:/tests
```
-1. Add this plugin:
+3. Add this plugin:
```bash
cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework.git
```
-1. Change the start page in `config.xml` with `` or navigate to cdvtests/index.html from within your app.
+4. Change the start page in `config.xml` with `` or navigate to cdvtests/index.html from within your app.
## Documentation
@@ -50,7 +50,22 @@ Many other plugins require Google Play Services and/or Firebase libraries. This
For example:
```
-cordova plugin add aerogear-cordova-push --variable FIREBASE_VERSION=11.8.0
+cordova plugin add aerogear-cordova-push --variable FIREBASE_VERSION=18.0.0
+```
+
+## AndroidX Support
+
+This plugin has [AndroidX](https://developer.android.com/jetpack/androidx) support. This means that you should migrate your project to AndroidX. To prevent to do it manually everytime, there are 2 great plugins to migrate it:
+
+1. First, enable AndroidX adding the [cordova-plugin-androidx](https://github.com/dpa99c/cordova-plugin-androidx) plugin:
+
+```
+cordova plugin add cordova-plugin-androidx
+```
+
+2. If you encounter build failures after installing (or after manually enabling AndroidX), try to install [cordova-plugin-androidx-adapter](https://github.com/dpa99c/cordova-plugin-androidx-adapter) into your project. It will migrate any references from the legacy Android Support library to use the new AndroidX which should resolve build failures.
+```
+cordova plugin add cordova-plugin-androidx-adapter
```
## Development
diff --git a/plugin.xml b/plugin.xml
index 87e7098..523e114 100755
--- a/plugin.xml
+++ b/plugin.xml
@@ -31,29 +31,19 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
+
diff --git a/scripts/androidBeforeInstall.js b/scripts/androidBeforeInstall.js
index 486249c..d4cc9ef 100644
--- a/scripts/androidBeforeInstall.js
+++ b/scripts/androidBeforeInstall.js
@@ -1,12 +1,8 @@
module.exports = function(ctx) {
var fs = require('fs'),
- path = require('path'),
os = require("os"),
readline = require("readline");
- var platformRoot = path.join(ctx.opts.projectRoot, 'www');
- var settingsFile = path.join(platformRoot, 'google-services.json');
-
var platformAndroid = 'platforms/android';
if (fs.existsSync('platforms/android/app/src/main')) {
@@ -15,28 +11,18 @@ module.exports = function(ctx) {
}
return new Promise(function(resolve, reject) {
- fs.stat(settingsFile, function(err,stats) {
- if (err) {
- reject("To use this plugin on android you'll need to add a google-services.json file with the FCM project_info and place that into your www folder");
- } else {
-
- fs.createReadStream(settingsFile).pipe(fs.createWriteStream(platformAndroid + '/google-services.json'));
-
- var lineReader = readline.createInterface({
- terminal: false,
- input : fs.createReadStream(platformAndroid + '/build.gradle')
- });
- lineReader.on("line", function(line) {
- fs.appendFileSync('./build.gradle', line.toString() + os.EOL);
- if (/.*\ dependencies \{.*/.test(line)) {
- fs.appendFileSync('./build.gradle', '\t\tclasspath "com.google.gms:google-services:3.0.0"' + os.EOL);
- fs.appendFileSync('./build.gradle', '\t\tclasspath "com.android.tools.build:gradle:1.2.3+"' + os.EOL);
- }
- }).on("close", function () {
- fs.rename('./build.gradle', platformAndroid + '/build.gradle', resolve);
- });
-
- }
- });
+ var lineReader = readline.createInterface({
+ terminal: false,
+ input : fs.createReadStream(platformAndroid + '/build.gradle')
+ });
+ lineReader.on("line", function(line) {
+ fs.appendFileSync('./build.gradle', line.toString() + os.EOL);
+ if (/.*\ dependencies \{.*/.test(line)) {
+ fs.appendFileSync('./build.gradle', '\t\tclasspath "com.google.gms:google-services:4.2.0"' + os.EOL);
+ fs.appendFileSync('./build.gradle', '\t\tclasspath "com.android.tools.build:gradle:3.3.0"' + os.EOL);
+ }
+ }).on("close", function () {
+ fs.rename('./build.gradle', platformAndroid + '/build.gradle', resolve);
+ });
})
};
diff --git a/src/android/dependencies.gradle b/src/android/dependencies.gradle
index 7ef0a47..edb845a 100644
--- a/src/android/dependencies.gradle
+++ b/src/android/dependencies.gradle
@@ -2,7 +2,7 @@ repositories {
mavenLocal()
}
-cdvMinSdkVersion = Math.max(16, cdvHelpers.getConfigPreference('android-minSdkVersion', 0) as Integer)
+//cdvMinSdkVersion = Math.max(16, cdvHelpers.getConfigPreference('android-minSdkVersion', 0) as Integer)
cdvPluginPostBuildExtras << {
apply plugin: 'com.google.gms.google-services'
}
@@ -17,15 +17,6 @@ if (file('src/main/AndroidManifest.xml').exists()) {
manifestFile = 'AndroidManifest.xml'
}
-import java.util.regex.Pattern
-
-def doExtractStringFromManifest(name) {
- def manifestFile = file(android.sourceSets.main.manifest.srcFile)
- def pattern = Pattern.compile(name + "=\"(.*?)\"")
- def matcher = pattern.matcher(manifestFile.getText())
- matcher.find()
- return matcher.group(1)
-}
android {
sourceSets {
@@ -42,6 +33,6 @@ android {
}
defaultConfig {
- applicationId = doExtractStringFromManifest("package")
+ applicationId cordovaConfig.PACKAGE_NAMESPACE
}
}
diff --git a/src/android/org/jboss/aerogear/cordova/push/NotificationMessageHandler.java b/src/android/org/jboss/aerogear/cordova/push/NotificationMessageHandler.java
index 37fb6ba..e0f5926 100644
--- a/src/android/org/jboss/aerogear/cordova/push/NotificationMessageHandler.java
+++ b/src/android/org/jboss/aerogear/cordova/push/NotificationMessageHandler.java
@@ -25,8 +25,9 @@
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.RequiresApi;
-import android.support.v4.app.NotificationCompat;
+
+import androidx.annotation.RequiresApi;
+import androidx.core.app.NotificationCompat;
import org.jboss.aerogear.android.store.DataManager;
import org.jboss.aerogear.android.store.sql.SQLStore;