From d248ee0d40508d148f460531ebaa7671141b341b Mon Sep 17 00:00:00 2001 From: gdeluna-branch Date: Tue, 10 Dec 2024 02:26:33 -0800 Subject: [PATCH] update android specific reqs --- android/build.gradle | 6 +- .../io/branch/rnbranch/RNBranchModule.java | 59 ++++++++++--------- package.json | 6 +- 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 14f75002a..66654d97d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,9 +1,9 @@ apply plugin: 'com.android.library' import groovy.json.JsonSlurper -def DEFAULT_COMPILE_SDK_VERSION = 29 +def DEFAULT_COMPILE_SDK_VERSION = 34 def DEFAULT_MIN_SDK_VERSION = 16 -def DEFAULT_TARGET_SDK_VERSION = 29 +def DEFAULT_TARGET_SDK_VERSION = 34 def getNpmVersion() { def packageJsonFile = file('../package.json') @@ -47,5 +47,5 @@ def safeExtGet(prop, fallback) { dependencies { implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0' implementation 'com.facebook.react:react-native:+' // From node_modules - api 'io.branch.sdk.android:library:5.12.4' + api 'io.branch.sdk.android:library:5.14.0' } diff --git a/android/src/main/java/io/branch/rnbranch/RNBranchModule.java b/android/src/main/java/io/branch/rnbranch/RNBranchModule.java index e3bb4c8ad..9e5138514 100644 --- a/android/src/main/java/io/branch/rnbranch/RNBranchModule.java +++ b/android/src/main/java/io/branch/rnbranch/RNBranchModule.java @@ -5,7 +5,6 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.BroadcastReceiver; -import android.graphics.Bitmap; import android.net.Uri; import android.util.Base64; @@ -178,7 +177,7 @@ private void generateLocalBroadcast(JSONObject referringParams, BranchUniversalObject branchUniversalObject, LinkProperties linkProperties, BranchError error) { - + Intent broadcastIntent = new Intent(NATIVE_INIT_SESSION_FINISHED_EVENT); if (referringParams != null) { @@ -210,7 +209,7 @@ private void generateLocalBroadcast(JSONObject referringParams, }.init(reactActivity); notifyJSOfInitSessionStart(reactActivity, uri); - + Branch.InitSessionBuilder initSessionBuilder = Branch.sessionBuilder(reactActivity).withCallback(referralInitListener).withData(uri); Log.d(REACT_CLASS, "sessionBuilder " + initSessionBuilder); initSessionBuilder.init(); @@ -261,6 +260,10 @@ public static void enableLogging() { Branch.enableLogging(); } + public static void enableLogging(BranchLogger.BranchLogLevel logLevel) { + Branch.enableLogging(logLevel); + } + public static void setRequestMetadata(String key, String val) { if (key == null) { return; @@ -336,7 +339,7 @@ private void listenForInitSessionEventsToReactNative(ReactApplicationContext rea public void onReceive(Context context, Intent intent) { final boolean hasError = (initSessionResult.has("error") && !initSessionResult.isNull("error")); final String eventName = hasError ? RN_INIT_SESSION_ERROR_EVENT : RN_INIT_SESSION_SUCCESS_EVENT; - + mBranchModule.sendRNEvent(eventName, convertJsonToMap(initSessionResult)); } @@ -374,8 +377,8 @@ private BroadcastReceiver init(RNBranchModule branchModule) { } @Override - public void onCatalystInstanceDestroy() { - Log.d(REACT_CLASS,"onCatalystInstanceDestroy "); + public void invalidate() { + Log.d(REACT_CLASS,"React instance invalidate()"); LocalBroadcastManager.getInstance(getReactApplicationContext()).unregisterReceiver(mInitSessionFinishedEventReceiver); LocalBroadcastManager.getInstance(getReactApplicationContext()).unregisterReceiver(mInitSessionStartedEventReceiver); @@ -444,15 +447,15 @@ public void getFirstReferringParams(Promise promise) { public void lastAttributedTouchData(int window, final Promise promise) { Branch branch = Branch.getInstance(); branch.getLastAttributedTouchData(new ServerRequestGetLATD.BranchLastAttributedTouchDataListener() { - @Override - public void onDataFetched(JSONObject jsonObject, BranchError error) { - if (error == null) { - promise.resolve(convertJsonToMap(jsonObject)); - } else { - promise.reject(GENERIC_ERROR, error.getMessage()); - } + @Override + public void onDataFetched(JSONObject jsonObject, BranchError error) { + if (error == null) { + promise.resolve(convertJsonToMap(jsonObject)); + } else { + promise.reject(GENERIC_ERROR, error.getMessage()); } - }, window); + } + }, window); } @ReactMethod @@ -461,7 +464,7 @@ public void setIdentity(String identity) { branch.setIdentity(identity); } - @ReactMethod + @ReactMethod public void setIdentityAsync(String identity, final Promise promise) { Branch branch = Branch.getInstance(); branch.setIdentity(identity, new Branch.BranchReferralInitListener() { @@ -633,7 +636,7 @@ private Branch.BranchLinkShareListener init(Promise promise) { public void registerView(String ident, Promise promise) { BranchUniversalObject branchUniversalObject = findUniversalObjectOrReject(ident, promise); if (branchUniversalObject == null) { - return; + return; } branchUniversalObject.registerView(); @@ -692,9 +695,9 @@ public void openURL(String url, ReadableMap options) { mActivity.startActivity(intent); } - @ReactMethod + @ReactMethod public void getBranchQRCode(ReadableMap branchQRCodeSettingsMap, ReadableMap branchUniversalObjectMap, ReadableMap linkPropertiesMap, ReadableMap controlParamsMap, final Promise promise) { - + BranchUniversalObject branchUniversalObject = createBranchUniversalObject(branchUniversalObjectMap); LinkProperties linkProperties = createLinkProperties(linkPropertiesMap, controlParamsMap); BranchQRCode qrCode = createBranchQRCode(branchQRCodeSettingsMap); @@ -706,13 +709,13 @@ public void onSuccess(byte[] qrCodeData) { String qrCodeString = Base64.encodeToString(qrCodeData, Base64.DEFAULT); promise.resolve(qrCodeString); } - + @Override public void onFailure(Exception e) { Log.d("Failed to get QR Code", e.getMessage()); promise.reject("Failed to get QR Code", e.getMessage()); - } - }); + } + }); } catch (IOException e) { e.printStackTrace(); Log.d("Failed to get QR Code", e.getMessage()); @@ -728,7 +731,7 @@ public BranchQRCode createBranchQRCode(ReadableMap branchQRCodeSettingsMap) { if (branchQRCodeSettingsMap.hasKey("centerLogo")) branchQRCode.setCenterLogo(branchQRCodeSettingsMap.getString("centerLogo")); if (branchQRCodeSettingsMap.hasKey("width")) branchQRCode.setWidth(branchQRCodeSettingsMap.getInt("width")); if (branchQRCodeSettingsMap.hasKey("margin")) branchQRCode.setMargin(branchQRCodeSettingsMap.getInt("margin")); - + if (branchQRCodeSettingsMap.hasKey("imageFormat")) { String imageFormat = branchQRCodeSettingsMap.getString("imageFormat"); if (imageFormat != null ) { @@ -780,7 +783,7 @@ public static BranchEvent createBranchEvent(String eventName, ReadableMap params ReadableMapKeySetIterator it = customData.keySetIterator(); while (it.hasNextKey()) { String key = it.nextKey(); - + ReadableType readableType = customData.getType(key); if(readableType == ReadableType.String) { event.addCustomDataProperty(key, customData.getString(key)); @@ -1085,9 +1088,9 @@ private Runnable init(ReactApplicationContext _context, Handler _mainHandler, St @Override public void run() { try { - Log.d(REACT_CLASS, "Catalyst instance poller try " + Integer.toString(tries)); - if (mContext.hasActiveCatalystInstance()) { - Log.d(REACT_CLASS, "Catalyst instance active"); + Log.d(REACT_CLASS, "React instance poller try " + Integer.toString(tries)); + if (mContext.hasActiveReactInstance()) { + Log.d(REACT_CLASS, "Has React instance"); mContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(mEventName, mParams); @@ -1096,12 +1099,12 @@ public void run() { if (tries <= maxTries) { mMainHandler.postDelayed(this, pollDelayInMs); } else { - Log.e(REACT_CLASS, "Could not get Catalyst instance"); + Log.e(REACT_CLASS, "Could not get React instance"); } } } catch (Exception e) { - e.printStackTrace(); + Log.e(REACT_CLASS, Objects.requireNonNull(e.getMessage())); } } }.init(context, mainHandler, eventName, params); diff --git a/package.json b/package.json index cb0557669..58885ce29 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-branch", - "version": "6.4.0", + "version": "7.0.0-alpha.1", "description": "Branch Metrics React Native SDK", "main": "src/index.js", "types": "src/index.d.ts", @@ -47,7 +47,7 @@ }, "homepage": "https://help.branch.io/developers-hub/docs/react-native", "peerDependencies": { - "react-native": ">= 0.60" + "react-native": ">= 0.70" }, "devDependencies": { "@babel/core": "^7.20.0", @@ -59,6 +59,6 @@ "eslint-config-rackt": "^1.1.1", "jest": "^29.2.1", "react": "18.2.0", - "react-native": "0.71.4" + "react-native": "0.76.3" } }