Skip to content

Commit

Permalink
update android specific reqs
Browse files Browse the repository at this point in the history
  • Loading branch information
gdeluna-branch committed Dec 10, 2024
1 parent 9c3fee8 commit d248ee0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 34 deletions.
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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'
}
59 changes: 31 additions & 28 deletions android/src/main/java/io/branch/rnbranch/RNBranchModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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());
Expand All @@ -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 ) {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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"
}
}

0 comments on commit d248ee0

Please sign in to comment.