mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 19:57:52 +01:00
mobile: remove all offender libs
This commit is contained in:
@@ -380,3 +380,5 @@ def isNewArchitectureEnabled() {
|
||||
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
|
||||
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
-dontwarn com.fingerprints.service.**
|
||||
|
||||
# Samsung Fingerprint
|
||||
|
||||
-keep class com.samsung.android.sdk.** { *; }
|
||||
-dontwarn com.samsung.android.sdk.**
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.dooboolab.RNIap.RNIapModule;
|
||||
import com.facebook.react.PackageList;
|
||||
import com.facebook.react.ReactApplication;
|
||||
import com.facebook.react.ReactInstanceManager;
|
||||
@@ -88,8 +87,6 @@ public class MainApplication extends MultiDexApplication implements ReactApplica
|
||||
return new DocumentPickerModule(reactContext);
|
||||
case "RNShare":
|
||||
return new RNShareModule(reactContext);
|
||||
case "RNIapModule":
|
||||
return new RNIapModule(reactContext);
|
||||
default:
|
||||
throw new IllegalArgumentException("Could not find module $name");
|
||||
}
|
||||
@@ -109,8 +106,6 @@ public class MainApplication extends MultiDexApplication implements ReactApplica
|
||||
map.put("RNFileViewer", getModuleInfo("RNFileViewer", "com.vinzscam.reactnativefileviewer.RNFileViewerModule"));
|
||||
map.put("RNDocumentPicker", getModuleInfo("RNDocumentPicker", "io.github.elyx0.reactnativedocumentpicker.DocumentPickerModule"));
|
||||
map.put("RNShare", getModuleInfo("RNShare", "cl.json.RNShareModule"));
|
||||
map.put("RNIapModule", getModuleInfo("RNIapModule", "com.dooboolab.RNIap.RNIapModule"));
|
||||
|
||||
return map;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
module.exports = {
|
||||
|
||||
const isGithubRelease = process.env.GITHUB_RELEASE;
|
||||
const config = {
|
||||
commands: require('@callstack/repack/commands'),
|
||||
project: {
|
||||
android: {
|
||||
@@ -6,3 +8,16 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (isGithubRelease) {
|
||||
config.dependencies = {
|
||||
"react-native-iap": {
|
||||
platforms: {
|
||||
android:null
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = config;
|
||||
|
||||
38
apps/mobile/patches/react-native-device-info+8.7.1.patch
Normal file
38
apps/mobile/patches/react-native-device-info+8.7.1.patch
Normal file
@@ -0,0 +1,38 @@
|
||||
diff --git a/node_modules/react-native-device-info/android/build.gradle b/node_modules/react-native-device-info/android/build.gradle
|
||||
index de22598..7d4dab9 100644
|
||||
--- a/node_modules/react-native-device-info/android/build.gradle
|
||||
+++ b/node_modules/react-native-device-info/android/build.gradle
|
||||
@@ -50,18 +50,6 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
|
||||
- implementation "com.android.installreferrer:installreferrer:${safeExtGet('installReferrerVersion', '1.1.2')}"
|
||||
- def firebaseBomVersion = safeExtGet("firebaseBomVersion", null)
|
||||
- def firebaseIidVersion = safeExtGet('firebaseIidVersion', null)
|
||||
- if (firebaseBomVersion) {
|
||||
- implementation platform("com.google.firebase:firebase-bom:${firebaseBomVersion}")
|
||||
- implementation "com.google.firebase:firebase-iid"
|
||||
- } else if(firebaseIidVersion){
|
||||
- implementation "com.google.firebase:firebase-iid:${firebaseIidVersion}"
|
||||
- }else{
|
||||
- def iidVersion = safeExtGet('googlePlayServicesIidVersion', safeExtGet('googlePlayServicesVersion', '17.0.0'))
|
||||
- implementation "com.google.android.gms:play-services-iid:$iidVersion"
|
||||
- }
|
||||
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
|
||||
testImplementation "org.mockito:mockito-core:3.6.28"
|
||||
diff --git a/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNInstallReferrerClient.java b/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNInstallReferrerClient.java
|
||||
index d02152b..a31992a 100644
|
||||
--- a/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNInstallReferrerClient.java
|
||||
+++ b/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNInstallReferrerClient.java
|
||||
@@ -19,9 +19,7 @@ public class RNInstallReferrerClient {
|
||||
InstallReferrerClientClazz = Class.forName("com.android.installreferrer.api.InstallReferrerClient");
|
||||
InstallReferrerStateListenerClazz = Class.forName("com.android.installreferrer.api.InstallReferrerStateListener");
|
||||
ReferrerDetailsClazz = Class.forName("com.android.installreferrer.api.ReferrerDetails");
|
||||
- } catch (Exception e) {
|
||||
- System.err.println("RNInstallReferrerClient exception. 'installreferrer' APIs are unavailable.");
|
||||
- }
|
||||
+ } catch (Exception e) {}
|
||||
}
|
||||
|
||||
private final SharedPreferences sharedPreferences;
|
||||
@@ -1,3 +1,291 @@
|
||||
diff --git a/node_modules/react-native-fingerprint-scanner/android/build.gradle b/node_modules/react-native-fingerprint-scanner/android/build.gradle
|
||||
index eaf3829..3ff988a 100644
|
||||
--- a/node_modules/react-native-fingerprint-scanner/android/build.gradle
|
||||
+++ b/node_modules/react-native-fingerprint-scanner/android/build.gradle
|
||||
@@ -45,9 +45,5 @@ dependencies {
|
||||
// androidx:biometric now supports fingerprint back to Android v23
|
||||
implementation "androidx.biometric:biometric:1.0.1"
|
||||
|
||||
- // retain fingerprintScanner lib for compat with Android v16-23 device-specific drivers (Samsung & MeiZu)
|
||||
- // 1.2.3 is the minimum version compatible with androidx.
|
||||
- // See https://github.com/uccmawei/FingerprintIdentify/issues/74
|
||||
- // (translation https://translate.google.com/translate?sl=zh-CN&tl=en&u=https://github.com/uccmawei/FingerprintIdentify/issues/74)
|
||||
- implementation "com.wei.android.lib:fingerprintidentify:${safeExtGet("fingerprintidentify", "1.2.6")}"
|
||||
+
|
||||
}
|
||||
diff --git a/node_modules/react-native-fingerprint-scanner/android/src/main/java/com/hieuvp/fingerprint/ReactNativeFingerprintScannerModule.java b/node_modules/react-native-fingerprint-scanner/android/src/main/java/com/hieuvp/fingerprint/ReactNativeFingerprintScannerModule.java
|
||||
index 2db879d..69e6f42 100644
|
||||
--- a/node_modules/react-native-fingerprint-scanner/android/src/main/java/com/hieuvp/fingerprint/ReactNativeFingerprintScannerModule.java
|
||||
+++ b/node_modules/react-native-fingerprint-scanner/android/src/main/java/com/hieuvp/fingerprint/ReactNativeFingerprintScannerModule.java
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.hieuvp.fingerprint;
|
||||
|
||||
+import android.annotation.TargetApi;
|
||||
import android.os.Build;
|
||||
+import android.app.KeyguardManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.biometric.BiometricPrompt;
|
||||
import androidx.biometric.BiometricManager;
|
||||
@@ -22,9 +24,7 @@ import com.facebook.react.bridge.UiThreadUtil;
|
||||
|
||||
// for Samsung/MeiZu compat, Android v16-23
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
|
||||
-import com.wei.android.lib.fingerprintidentify.FingerprintIdentify;
|
||||
-import com.wei.android.lib.fingerprintidentify.base.BaseFingerprint.ExceptionListener;
|
||||
-import com.wei.android.lib.fingerprintidentify.base.BaseFingerprint.IdentifyListener;
|
||||
+import static android.content.Context.KEYGUARD_SERVICE;
|
||||
|
||||
|
||||
@ReactModule(name="ReactNativeFingerprintScanner")
|
||||
@@ -38,13 +38,14 @@ public class ReactNativeFingerprintScannerModule
|
||||
|
||||
private final ReactApplicationContext mReactContext;
|
||||
private BiometricPrompt biometricPrompt;
|
||||
+ private KeyguardManager mKeyguardManager;
|
||||
+ private boolean mDeviceCredentialAllowed = false;
|
||||
|
||||
- // for Samsung/MeiZu compat, Android v16-23
|
||||
- private FingerprintIdentify mFingerprintIdentify;
|
||||
|
||||
public ReactNativeFingerprintScannerModule(ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
mReactContext = reactContext;
|
||||
+ mKeyguardManager = (KeyguardManager) reactContext.getSystemService(KEYGUARD_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,7 +71,12 @@ public class ReactNativeFingerprintScannerModule
|
||||
}
|
||||
|
||||
private boolean requiresLegacyAuthentication() {
|
||||
- return currentAndroidVersion() < 23;
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ @TargetApi(23)
|
||||
+ private boolean isDeviceSecure() {
|
||||
+ return currentAndroidVersion() >= 23 && mKeyguardManager.isDeviceSecure();
|
||||
}
|
||||
|
||||
public class AuthCallback extends BiometricPrompt.AuthenticationCallback {
|
||||
@@ -94,7 +100,7 @@ public class ReactNativeFingerprintScannerModule
|
||||
}
|
||||
}
|
||||
|
||||
- public BiometricPrompt getBiometricPrompt(final Promise promise) {
|
||||
+ public BiometricPrompt getBiometricPrompt(final FragmentActivity fragmentActivity, final Promise promise) {
|
||||
// memoize so can be accessed to cancel
|
||||
if (biometricPrompt != null) {
|
||||
return biometricPrompt;
|
||||
@@ -104,12 +110,11 @@ public class ReactNativeFingerprintScannerModule
|
||||
mReactContext.addLifecycleEventListener(this);
|
||||
|
||||
AuthCallback authCallback = new AuthCallback(promise);
|
||||
- FragmentActivity fragmentActivity = (FragmentActivity) getCurrentActivity();
|
||||
Executor executor = Executors.newSingleThreadExecutor();
|
||||
biometricPrompt = new BiometricPrompt(
|
||||
- fragmentActivity,
|
||||
- executor,
|
||||
- authCallback
|
||||
+ fragmentActivity,
|
||||
+ executor,
|
||||
+ authCallback
|
||||
);
|
||||
|
||||
return biometricPrompt;
|
||||
@@ -120,18 +125,27 @@ public class ReactNativeFingerprintScannerModule
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
- BiometricPrompt bioPrompt = getBiometricPrompt(promise);
|
||||
+ FragmentActivity fragmentActivity = (FragmentActivity) mReactContext.getCurrentActivity();
|
||||
+
|
||||
+ if(fragmentActivity == null) return;
|
||||
+
|
||||
+ BiometricPrompt bioPrompt = getBiometricPrompt(fragmentActivity, promise);
|
||||
+ boolean allowDeviceCredential = mDeviceCredentialAllowed &&
|
||||
+ isDeviceSecure();
|
||||
|
||||
- PromptInfo promptInfo = new BiometricPrompt.PromptInfo.Builder()
|
||||
- .setDeviceCredentialAllowed(false)
|
||||
+ PromptInfo.Builder promptInfo = new BiometricPrompt.PromptInfo.Builder()
|
||||
+ .setDeviceCredentialAllowed(allowDeviceCredential)
|
||||
.setConfirmationRequired(false)
|
||||
- .setNegativeButtonText(cancelButton)
|
||||
.setDescription(description)
|
||||
.setSubtitle(subtitle)
|
||||
- .setTitle(title)
|
||||
- .build();
|
||||
+ .setTitle(title);
|
||||
|
||||
- bioPrompt.authenticate(promptInfo);
|
||||
+ // This should not be set if a backup is allowed (PIN/Pattern/Password)
|
||||
+ if(!allowDeviceCredential) {
|
||||
+ promptInfo = promptInfo.setNegativeButtonText(cancelButton);
|
||||
+ }
|
||||
+
|
||||
+ bioPrompt.authenticate(promptInfo.build());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -208,10 +222,6 @@ public class ReactNativeFingerprintScannerModule
|
||||
|
||||
@ReactMethod
|
||||
public void release() {
|
||||
- if (requiresLegacyAuthentication()) {
|
||||
- getFingerprintIdentify().cancelIdentify();
|
||||
- mFingerprintIdentify = null;
|
||||
- }
|
||||
|
||||
// consistent across legacy and current API
|
||||
if (biometricPrompt != null) {
|
||||
@@ -242,35 +252,13 @@ public class ReactNativeFingerprintScannerModule
|
||||
}
|
||||
}
|
||||
|
||||
-
|
||||
- // for Samsung/MeiZu compat, Android v16-23
|
||||
- private FingerprintIdentify getFingerprintIdentify() {
|
||||
- if (mFingerprintIdentify != null) {
|
||||
- return mFingerprintIdentify;
|
||||
- }
|
||||
- mReactContext.addLifecycleEventListener(this);
|
||||
- mFingerprintIdentify = new FingerprintIdentify(mReactContext);
|
||||
- mFingerprintIdentify.setSupportAndroidL(true);
|
||||
- mFingerprintIdentify.setExceptionListener(
|
||||
- new ExceptionListener() {
|
||||
- @Override
|
||||
- public void onCatchException(Throwable exception) {
|
||||
- mReactContext.removeLifecycleEventListener(ReactNativeFingerprintScannerModule.this);
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- mFingerprintIdentify.init();
|
||||
- return mFingerprintIdentify;
|
||||
+ @ReactMethod
|
||||
+ public void setDeviceCredentialAllowed(boolean allowed) {
|
||||
+ mDeviceCredentialAllowed = allowed;
|
||||
}
|
||||
|
||||
private String legacyGetErrorMessage() {
|
||||
- if (!getFingerprintIdentify().isHardwareEnable()) {
|
||||
- return "FingerprintScannerNotSupported";
|
||||
- } else if (!getFingerprintIdentify().isRegisteredFingerprint()) {
|
||||
- return "FingerprintScannerNotEnrolled";
|
||||
- } else if (!getFingerprintIdentify().isFingerprintEnable()) {
|
||||
- return "FingerprintScannerNotAvailable";
|
||||
- }
|
||||
+
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -283,41 +271,5 @@ public class ReactNativeFingerprintScannerModule
|
||||
ReactNativeFingerprintScannerModule.this.release();
|
||||
return;
|
||||
}
|
||||
-
|
||||
- getFingerprintIdentify().resumeIdentify();
|
||||
- getFingerprintIdentify().startIdentify(MAX_AVAILABLE_TIMES, new IdentifyListener() {
|
||||
- @Override
|
||||
- public void onSucceed() {
|
||||
- promise.resolve(true);
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public void onNotMatch(int availableTimes) {
|
||||
- if (availableTimes <= 0) {
|
||||
- mReactContext.getJSModule(RCTDeviceEventEmitter.class)
|
||||
- .emit("FINGERPRINT_SCANNER_AUTHENTICATION", "DeviceLocked");
|
||||
-
|
||||
- } else {
|
||||
- mReactContext.getJSModule(RCTDeviceEventEmitter.class)
|
||||
- .emit("FINGERPRINT_SCANNER_AUTHENTICATION", "AuthenticationNotMatch");
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public void onFailed(boolean isDeviceLocked) {
|
||||
- if(isDeviceLocked){
|
||||
- promise.reject("AuthenticationFailed", "DeviceLocked");
|
||||
- } else {
|
||||
- promise.reject("AuthenticationFailed", TYPE_FINGERPRINT_LEGACY);
|
||||
- }
|
||||
- ReactNativeFingerprintScannerModule.this.release();
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public void onStartFailedByDeviceLocked() {
|
||||
- // the first start failed because the device was locked temporarily
|
||||
- promise.reject("AuthenticationFailed", "DeviceLocked");
|
||||
- }
|
||||
- });
|
||||
}
|
||||
}
|
||||
diff --git a/node_modules/react-native-fingerprint-scanner/ios/ReactNativeFingerprintScanner.m b/node_modules/react-native-fingerprint-scanner/ios/ReactNativeFingerprintScanner.m
|
||||
index e29bad7..d760e01 100644
|
||||
--- a/node_modules/react-native-fingerprint-scanner/ios/ReactNativeFingerprintScanner.m
|
||||
+++ b/node_modules/react-native-fingerprint-scanner/ios/ReactNativeFingerprintScanner.m
|
||||
@@ -65,10 +65,19 @@ @implementation ReactNativeFingerprintScanner
|
||||
context.localizedFallbackTitle = @"";
|
||||
}
|
||||
|
||||
+ __auto_type policy = LAPolicyDeviceOwnerAuthenticationWithBiometrics;
|
||||
+
|
||||
+ if (@available(iOS 9, *)) {
|
||||
+ if (fallbackEnabled) {
|
||||
+ policy = LAPolicyDeviceOwnerAuthentication;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
// Device has FingerprintScanner
|
||||
- if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
|
||||
+ if ([context canEvaluatePolicy:policy error:&error]) {
|
||||
// Attempt Authentication
|
||||
- [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
|
||||
+ [context evaluatePolicy:policy
|
||||
localizedReason:reason
|
||||
reply:^(BOOL success, NSError *error)
|
||||
{
|
||||
diff --git a/node_modules/react-native-fingerprint-scanner/package-lock.json b/node_modules/react-native-fingerprint-scanner/package-lock.json
|
||||
deleted file mode 100644
|
||||
index 1cc934c..0000000
|
||||
--- a/node_modules/react-native-fingerprint-scanner/package-lock.json
|
||||
+++ /dev/null
|
||||
@@ -1,5 +0,0 @@
|
||||
-{
|
||||
- "name": "react-native-fingerprint-scanner",
|
||||
- "version": "4.0.0",
|
||||
- "lockfileVersion": 1
|
||||
-}
|
||||
diff --git a/node_modules/react-native-fingerprint-scanner/react-native-fingerprint-scanner.podspec b/node_modules/react-native-fingerprint-scanner/react-native-fingerprint-scanner.podspec
|
||||
index e9fbd07..699fd80 100644
|
||||
--- a/node_modules/react-native-fingerprint-scanner/react-native-fingerprint-scanner.podspec
|
||||
+++ b/node_modules/react-native-fingerprint-scanner/react-native-fingerprint-scanner.podspec
|
||||
@@ -3,19 +3,18 @@ require 'json'
|
||||
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
- s.name = package['name']
|
||||
+ s.name = 'react-native-fingerprint-scanner'
|
||||
s.version = package['version']
|
||||
s.summary = package['description']
|
||||
s.license = package['license']
|
||||
-
|
||||
s.authors = package['author']
|
||||
s.homepage = package['homepage']
|
||||
- s.platform = :ios, "9.0"
|
||||
+ s.platform = :ios, "8.0"
|
||||
|
||||
- s.source = { :git => "https://github.com/hieuvp/react-native-fingerprint-scanner.git", :tag => "v#{s.version}" }
|
||||
+ s.source = { :git => package['repository']['url'], :tag => s.version }
|
||||
s.source_files = 'ios/**/*.{h,m}'
|
||||
s.preserve_paths = '**/*.js'
|
||||
s.framework = 'LocalAuthentication'
|
||||
|
||||
- s.dependency 'React'
|
||||
+ s.dependency 'React-Core'
|
||||
end
|
||||
diff --git a/node_modules/react-native-fingerprint-scanner/react-native.config.js b/node_modules/react-native-fingerprint-scanner/react-native.config.js
|
||||
deleted file mode 100644
|
||||
index 5f794ab..0000000
|
||||
@@ -15,3 +303,27 @@ index 5f794ab..0000000
|
||||
- hooks: {},
|
||||
- },
|
||||
-};
|
||||
diff --git a/node_modules/react-native-fingerprint-scanner/src/authenticate.android.js b/node_modules/react-native-fingerprint-scanner/src/authenticate.android.js
|
||||
index f01ae83..b2bcd40 100644
|
||||
--- a/node_modules/react-native-fingerprint-scanner/src/authenticate.android.js
|
||||
+++ b/node_modules/react-native-fingerprint-scanner/src/authenticate.android.js
|
||||
@@ -38,7 +38,7 @@ const authLegacy = (onAttempt, resolve, reject) => {
|
||||
|
||||
const nullOnAttempt = () => null;
|
||||
|
||||
-export default ({ title, subTitle, description, cancelButton, onAttempt }) => {
|
||||
+export default ({ title, subTitle, description, cancelButton, onAttempt, deviceCredentialAllowed = false }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!title) {
|
||||
title = description ? description : "Log In";
|
||||
@@ -61,6 +61,10 @@ export default ({ title, subTitle, description, cancelButton, onAttempt }) => {
|
||||
return authLegacy(onAttempt, resolve, reject);
|
||||
}
|
||||
|
||||
+ if (Platform.Version >= 29 && deviceCredentialAllowed === true) {
|
||||
+ ReactNativeFingerprintScanner.setDeviceCredentialAllowed(true);
|
||||
+ }
|
||||
+
|
||||
return authCurrent(title, subTitle, description, cancelButton, resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,3 +1,91 @@
|
||||
diff --git a/node_modules/react-native-push-notification/android/build.gradle b/node_modules/react-native-push-notification/android/build.gradle
|
||||
index d6019f6..1f7e5d1 100644
|
||||
--- a/node_modules/react-native-push-notification/android/build.gradle
|
||||
+++ b/node_modules/react-native-push-notification/android/build.gradle
|
||||
@@ -60,5 +60,4 @@ dependencies {
|
||||
implementation "$appCompatLibName:$supportLibVersion"
|
||||
implementation 'com.facebook.react:react-native:+'
|
||||
implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
|
||||
- implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '21.1.0')}"
|
||||
}
|
||||
diff --git a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotification.java b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotification.java
|
||||
index d162680..56c5a76 100644
|
||||
--- a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotification.java
|
||||
+++ b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotification.java
|
||||
@@ -2,14 +2,11 @@ package com.dieam.reactnativepushnotification.modules;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
-import android.app.NotificationManager;
|
||||
-import android.content.BroadcastReceiver;
|
||||
-import android.content.Context;
|
||||
import android.content.Intent;
|
||||
-import android.content.IntentFilter;
|
||||
+import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
-import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
+import androidx.annotation.RequiresApi;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
import com.dieam.reactnativepushnotification.helpers.ApplicationBadgeHelper;
|
||||
@@ -26,7 +23,6 @@ import com.facebook.react.bridge.WritableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
|
||||
-import java.io.IOException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -34,9 +30,6 @@ import java.util.Map;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
-import com.google.android.gms.tasks.OnCompleteListener;
|
||||
-import com.google.android.gms.tasks.Task;
|
||||
-import com.google.firebase.messaging.FirebaseMessaging;
|
||||
|
||||
public class RNPushNotification extends ReactContextBaseJavaModule implements ActivityEventListener {
|
||||
public static final String LOG_TAG = "RNPushNotification";// all logging should use this tag
|
||||
@@ -137,30 +130,6 @@ public class RNPushNotification extends ReactContextBaseJavaModule implements Ac
|
||||
public void requestPermissions() {
|
||||
final RNPushNotificationJsDelivery fMjsDelivery = mJsDelivery;
|
||||
|
||||
- FirebaseMessaging.getInstance().getToken()
|
||||
- .addOnCompleteListener(new OnCompleteListener<String>() {
|
||||
- @Override
|
||||
- public void onComplete(@NonNull Task<String> task) {
|
||||
- if (!task.isSuccessful()) {
|
||||
- Log.e(LOG_TAG, "exception", task.getException());
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
- WritableMap params = Arguments.createMap();
|
||||
- params.putString("deviceToken", task.getResult());
|
||||
- fMjsDelivery.sendEvent("remoteNotificationsRegistered", params);
|
||||
- }
|
||||
- });
|
||||
- }
|
||||
-
|
||||
- @ReactMethod
|
||||
- public void subscribeToTopic(String topic) {
|
||||
- FirebaseMessaging.getInstance().subscribeToTopic(topic);
|
||||
- }
|
||||
-
|
||||
- @ReactMethod
|
||||
- public void unsubscribeFromTopic(String topic) {
|
||||
- FirebaseMessaging.getInstance().unsubscribeFromTopic(topic);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
@@ -280,7 +249,6 @@ public class RNPushNotification extends ReactContextBaseJavaModule implements Ac
|
||||
* Unregister for all remote notifications received
|
||||
*/
|
||||
public void abandonPermissions() {
|
||||
- FirebaseMessaging.getInstance().deleteToken();
|
||||
Log.i(LOG_TAG, "InstanceID deleted");
|
||||
}
|
||||
|
||||
diff --git a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java
|
||||
index 248ff08..ff198d5 100644
|
||||
--- a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java
|
||||
@@ -44,3 +132,309 @@ index 248ff08..ff198d5 100644
|
||||
|
||||
PendingIntent pendingActionIntent = PendingIntent.getBroadcast(context, notificationID, actionIntent, flags);
|
||||
|
||||
diff --git a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationListenerService.java b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationListenerService.java
|
||||
index ca78c03..9ee3650 100644
|
||||
--- a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationListenerService.java
|
||||
+++ b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationListenerService.java
|
||||
@@ -1,79 +1,5 @@
|
||||
package com.dieam.reactnativepushnotification.modules;
|
||||
|
||||
-import com.google.firebase.messaging.FirebaseMessagingService;
|
||||
-import com.google.firebase.messaging.RemoteMessage;
|
||||
+public class RNPushNotificationListenerService {
|
||||
|
||||
-import android.os.Handler;
|
||||
-import android.os.Looper;
|
||||
-import android.util.Log;
|
||||
-
|
||||
-import com.facebook.react.ReactApplication;
|
||||
-import com.facebook.react.ReactInstanceManager;
|
||||
-import com.facebook.react.bridge.Arguments;
|
||||
-import com.facebook.react.bridge.ReactApplicationContext;
|
||||
-import com.facebook.react.bridge.ReactContext;
|
||||
-import com.facebook.react.bridge.WritableMap;
|
||||
-
|
||||
-import static com.dieam.reactnativepushnotification.modules.RNPushNotification.LOG_TAG;
|
||||
-
|
||||
-public class RNPushNotificationListenerService extends FirebaseMessagingService {
|
||||
-
|
||||
- private RNReceivedMessageHandler mMessageReceivedHandler;
|
||||
- private FirebaseMessagingService mFirebaseServiceDelegate;
|
||||
-
|
||||
- public RNPushNotificationListenerService() {
|
||||
- super();
|
||||
- this.mMessageReceivedHandler = new RNReceivedMessageHandler(this);
|
||||
- }
|
||||
-
|
||||
- public RNPushNotificationListenerService(FirebaseMessagingService delegate) {
|
||||
- super();
|
||||
- this.mFirebaseServiceDelegate = delegate;
|
||||
- this.mMessageReceivedHandler = new RNReceivedMessageHandler(delegate);
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public void onNewToken(String token) {
|
||||
- final String deviceToken = token;
|
||||
- final FirebaseMessagingService serviceRef = (this.mFirebaseServiceDelegate == null) ? this : this.mFirebaseServiceDelegate;
|
||||
- Log.d(LOG_TAG, "Refreshed token: " + deviceToken);
|
||||
-
|
||||
- Handler handler = new Handler(Looper.getMainLooper());
|
||||
- handler.post(new Runnable() {
|
||||
- public void run() {
|
||||
- // Construct and load our normal React JS code bundle
|
||||
- final ReactInstanceManager mReactInstanceManager = ((ReactApplication)serviceRef.getApplication()).getReactNativeHost().getReactInstanceManager();
|
||||
- ReactContext context = mReactInstanceManager.getCurrentReactContext();
|
||||
- // If it's constructed, send a notification
|
||||
- if (context != null) {
|
||||
- handleNewToken((ReactApplicationContext) context, deviceToken);
|
||||
- } else {
|
||||
- // Otherwise wait for construction, then send the notification
|
||||
- mReactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
|
||||
- public void onReactContextInitialized(ReactContext context) {
|
||||
- handleNewToken((ReactApplicationContext) context, deviceToken);
|
||||
- mReactInstanceManager.removeReactInstanceEventListener(this);
|
||||
- }
|
||||
- });
|
||||
- if (!mReactInstanceManager.hasStartedCreatingInitialContext()) {
|
||||
- // Construct it in the background
|
||||
- mReactInstanceManager.createReactContextInBackground();
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- });
|
||||
- }
|
||||
-
|
||||
- private void handleNewToken(ReactApplicationContext context, String token) {
|
||||
- RNPushNotificationJsDelivery jsDelivery = new RNPushNotificationJsDelivery(context);
|
||||
-
|
||||
- WritableMap params = Arguments.createMap();
|
||||
- params.putString("deviceToken", token);
|
||||
- jsDelivery.sendEvent("remoteNotificationsRegistered", params);
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public void onMessageReceived(RemoteMessage message) {
|
||||
- mMessageReceivedHandler.handleReceivedMessage(message);
|
||||
- }
|
||||
}
|
||||
diff --git a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNReceivedMessageHandler.java b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNReceivedMessageHandler.java
|
||||
index 721ca40..b7bff2f 100644
|
||||
--- a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNReceivedMessageHandler.java
|
||||
+++ b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNReceivedMessageHandler.java
|
||||
@@ -1,215 +1,6 @@
|
||||
package com.dieam.reactnativepushnotification.modules;
|
||||
|
||||
-import com.google.firebase.messaging.FirebaseMessagingService;
|
||||
-import com.google.firebase.messaging.RemoteMessage;
|
||||
-
|
||||
-import android.app.ActivityManager;
|
||||
-import android.app.ActivityManager.RunningAppProcessInfo;
|
||||
-import android.app.Application;
|
||||
-import android.os.Bundle;
|
||||
-import android.os.Handler;
|
||||
-import android.os.Looper;
|
||||
-import android.content.Context;
|
||||
-import android.util.Log;
|
||||
-import android.net.Uri;
|
||||
-import androidx.annotation.NonNull;
|
||||
-import androidx.core.app.NotificationCompat;
|
||||
-
|
||||
-import com.dieam.reactnativepushnotification.helpers.ApplicationBadgeHelper;
|
||||
-import com.facebook.react.ReactApplication;
|
||||
-import com.facebook.react.ReactInstanceManager;
|
||||
-import com.facebook.react.bridge.ReactApplicationContext;
|
||||
-import com.facebook.react.bridge.ReactContext;
|
||||
-
|
||||
-import org.json.JSONObject;
|
||||
-
|
||||
-import java.util.Map;
|
||||
-import java.util.List;
|
||||
-import java.security.SecureRandom;
|
||||
-
|
||||
-import static android.content.Context.ACTIVITY_SERVICE;
|
||||
-import static com.dieam.reactnativepushnotification.modules.RNPushNotification.LOG_TAG;
|
||||
-
|
||||
public class RNReceivedMessageHandler {
|
||||
- private FirebaseMessagingService mFirebaseMessagingService;
|
||||
-
|
||||
- public RNReceivedMessageHandler(@NonNull FirebaseMessagingService service) {
|
||||
- this.mFirebaseMessagingService = service;
|
||||
- }
|
||||
-
|
||||
- public void handleReceivedMessage(RemoteMessage message) {
|
||||
- String from = message.getFrom();
|
||||
- RemoteMessage.Notification remoteNotification = message.getNotification();
|
||||
- final Bundle bundle = new Bundle();
|
||||
- // Putting it from remoteNotification first so it can be overriden if message
|
||||
- // data has it
|
||||
- if (remoteNotification != null) {
|
||||
- // ^ It's null when message is from GCM
|
||||
- RNPushNotificationConfig config = new RNPushNotificationConfig(mFirebaseMessagingService.getApplication());
|
||||
-
|
||||
- String title = getLocalizedString(remoteNotification.getTitle(), remoteNotification.getTitleLocalizationKey(), remoteNotification.getTitleLocalizationArgs());
|
||||
- String body = getLocalizedString(remoteNotification.getBody(), remoteNotification.getBodyLocalizationKey(), remoteNotification.getBodyLocalizationArgs());
|
||||
-
|
||||
- bundle.putString("title", title);
|
||||
- bundle.putString("message", body);
|
||||
- bundle.putString("sound", remoteNotification.getSound());
|
||||
- bundle.putString("color", remoteNotification.getColor());
|
||||
- bundle.putString("tag", remoteNotification.getTag());
|
||||
-
|
||||
- if(remoteNotification.getIcon() != null) {
|
||||
- bundle.putString("smallIcon", remoteNotification.getIcon());
|
||||
- } else {
|
||||
- bundle.putString("smallIcon", "ic_notification");
|
||||
- }
|
||||
-
|
||||
- if(remoteNotification.getChannelId() != null) {
|
||||
- bundle.putString("channelId", remoteNotification.getChannelId());
|
||||
- }
|
||||
- else {
|
||||
- bundle.putString("channelId", config.getNotificationDefaultChannelId());
|
||||
- }
|
||||
-
|
||||
- Integer visibilty = remoteNotification.getVisibility();
|
||||
- String visibilityString = "private";
|
||||
-
|
||||
- if (visibilty != null) {
|
||||
- switch (visibilty) {
|
||||
- case NotificationCompat.VISIBILITY_PUBLIC:
|
||||
- visibilityString = "public";
|
||||
- break;
|
||||
- case NotificationCompat.VISIBILITY_SECRET:
|
||||
- visibilityString = "secret";
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- bundle.putString("visibility", visibilityString);
|
||||
-
|
||||
- Integer priority = remoteNotification.getNotificationPriority();
|
||||
- String priorityString = "high";
|
||||
-
|
||||
- if (priority != null) {
|
||||
- switch (priority) {
|
||||
- case NotificationCompat.PRIORITY_MAX:
|
||||
- priorityString = "max";
|
||||
- break;
|
||||
- case NotificationCompat.PRIORITY_LOW:
|
||||
- priorityString = "low";
|
||||
- break;
|
||||
- case NotificationCompat.PRIORITY_MIN:
|
||||
- priorityString = "min";
|
||||
- break;
|
||||
- case NotificationCompat.PRIORITY_DEFAULT:
|
||||
- priorityString = "default";
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- bundle.putString("priority", priorityString);
|
||||
-
|
||||
- Uri uri = remoteNotification.getImageUrl();
|
||||
-
|
||||
- if(uri != null) {
|
||||
- String imageUrl = uri.toString();
|
||||
|
||||
- bundle.putString("bigPictureUrl", imageUrl);
|
||||
- bundle.putString("largeIconUrl", imageUrl);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- Bundle dataBundle = new Bundle();
|
||||
- Map<String, String> notificationData = message.getData();
|
||||
-
|
||||
- for(Map.Entry<String, String> entry : notificationData.entrySet()) {
|
||||
- dataBundle.putString(entry.getKey(), entry.getValue());
|
||||
- }
|
||||
-
|
||||
- bundle.putParcelable("data", dataBundle);
|
||||
-
|
||||
- Log.v(LOG_TAG, "onMessageReceived: " + bundle);
|
||||
-
|
||||
- // We need to run this on the main thread, as the React code assumes that is true.
|
||||
- // Namely, DevServerHelper constructs a Handler() without a Looper, which triggers:
|
||||
- // "Can't create handler inside thread that has not called Looper.prepare()"
|
||||
- Handler handler = new Handler(Looper.getMainLooper());
|
||||
- handler.post(new Runnable() {
|
||||
- public void run() {
|
||||
- // Construct and load our normal React JS code bundle
|
||||
- final ReactInstanceManager mReactInstanceManager = ((ReactApplication) mFirebaseMessagingService.getApplication()).getReactNativeHost().getReactInstanceManager();
|
||||
- ReactContext context = mReactInstanceManager.getCurrentReactContext();
|
||||
- // If it's constructed, send a notificationre
|
||||
- if (context != null) {
|
||||
- handleRemotePushNotification((ReactApplicationContext) context, bundle);
|
||||
- } else {
|
||||
- // Otherwise wait for construction, then send the notification
|
||||
- mReactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
|
||||
- public void onReactContextInitialized(ReactContext context) {
|
||||
- handleRemotePushNotification((ReactApplicationContext) context, bundle);
|
||||
- mReactInstanceManager.removeReactInstanceEventListener(this);
|
||||
- }
|
||||
- });
|
||||
- if (!mReactInstanceManager.hasStartedCreatingInitialContext()) {
|
||||
- // Construct it in the background
|
||||
- mReactInstanceManager.createReactContextInBackground();
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- });
|
||||
- }
|
||||
-
|
||||
- private void handleRemotePushNotification(ReactApplicationContext context, Bundle bundle) {
|
||||
-
|
||||
- // If notification ID is not provided by the user for push notification, generate one at random
|
||||
- if (bundle.getString("id") == null) {
|
||||
- SecureRandom randomNumberGenerator = new SecureRandom();
|
||||
- bundle.putString("id", String.valueOf(randomNumberGenerator.nextInt()));
|
||||
- }
|
||||
-
|
||||
- Application applicationContext = (Application) context.getApplicationContext();
|
||||
-
|
||||
- RNPushNotificationConfig config = new RNPushNotificationConfig(mFirebaseMessagingService.getApplication());
|
||||
- RNPushNotificationHelper pushNotificationHelper = new RNPushNotificationHelper(applicationContext);
|
||||
-
|
||||
- boolean isForeground = pushNotificationHelper.isApplicationInForeground();
|
||||
-
|
||||
- RNPushNotificationJsDelivery jsDelivery = new RNPushNotificationJsDelivery(context);
|
||||
- bundle.putBoolean("foreground", isForeground);
|
||||
- bundle.putBoolean("userInteraction", false);
|
||||
- jsDelivery.notifyNotification(bundle);
|
||||
-
|
||||
- // If contentAvailable is set to true, then send out a remote fetch event
|
||||
- if (bundle.getString("contentAvailable", "false").equalsIgnoreCase("true")) {
|
||||
- jsDelivery.notifyRemoteFetch(bundle);
|
||||
- }
|
||||
-
|
||||
- if (config.getNotificationForeground() || !isForeground) {
|
||||
- Log.v(LOG_TAG, "sendNotification: " + bundle);
|
||||
-
|
||||
- pushNotificationHelper.sendToNotificationCentre(bundle);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- private String getLocalizedString(String text, String locKey, String[] locArgs) {
|
||||
- if(text != null) {
|
||||
- return text;
|
||||
- }
|
||||
-
|
||||
- Context context = mFirebaseMessagingService.getApplicationContext();
|
||||
- String packageName = context.getPackageName();
|
||||
-
|
||||
- String result = null;
|
||||
-
|
||||
- if (locKey != null) {
|
||||
- int id = context.getResources().getIdentifier(locKey, "string", packageName);
|
||||
- if (id != 0) {
|
||||
- if (locArgs != null) {
|
||||
- result = context.getResources().getString(id, (Object[]) locArgs);
|
||||
- } else {
|
||||
- result = context.getResources().getString(id);
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- return result;
|
||||
- }
|
||||
}
|
||||
+
|
||||
|
||||
Reference in New Issue
Block a user