From 2a2e15d50338c45f1c774c09703c92174b2df79c Mon Sep 17 00:00:00 2001 From: wesleyorbin Date: Wed, 7 Oct 2020 17:49:58 -0400 Subject: [PATCH] Release version 1.24.0 --- AppboyProject/android/app/build.gradle | 15 +- AppboyProject/android/build.gradle | 8 +- .../gradle/wrapper/gradle-wrapper.properties | 3 +- AppboyProject/ios/Podfile | 2 +- AppboyProject/ios/Podfile.lock | 40 +- AppboyProject/yarn.lock | 2 +- CHANGELOG.md | 6 + android/build.gradle | 2 +- .../appboy/reactbridge/AppboyReactBridge.java | 447 ++++++++++++------ .../reactbridge/AppboyReactPackage.java | 11 +- package.json | 2 +- react-native-appboy-sdk.podspec | 2 +- 12 files changed, 357 insertions(+), 183 deletions(-) diff --git a/AppboyProject/android/app/build.gradle b/AppboyProject/android/app/build.gradle index 038adbf..743db51 100644 --- a/AppboyProject/android/app/build.gradle +++ b/AppboyProject/android/app/build.gradle @@ -95,13 +95,13 @@ def enableSeparateBuildPerCPUArchitecture = false def enableProguardInReleaseBuilds = false android { - compileSdkVersion 28 - buildToolsVersion "28.0.3" + compileSdkVersion 30 + buildToolsVersion "30.0.2" defaultConfig { applicationId "com.appboyproject" minSdkVersion 16 - targetSdkVersion 28 + targetSdkVersion 30 versionCode 1 versionName "1.0" ndk { @@ -135,16 +135,21 @@ android { } } } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } def jscFlavor = 'org.webkit:android-jsc:+' def enableHermes = project.ext.react.get("enableHermes", false) dependencies { - implementation "com.google.firebase:firebase-messaging:17.3.4" + implementation "com.google.firebase:firebase-messaging:20.3.0" implementation project(':react-native-appboy-sdk') implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation "com.android.support:appcompat-v7:28.0.0" + implementation 'androidx.appcompat:appcompat:1.2.0' implementation "com.facebook.react:react-native:+" // From node_modules if (enableHermes) { // For RN 0.60.x diff --git a/AppboyProject/android/build.gradle b/AppboyProject/android/build.gradle index 2ed14f9..db0be63 100644 --- a/AppboyProject/android/build.gradle +++ b/AppboyProject/android/build.gradle @@ -3,11 +3,11 @@ buildscript { repositories { jcenter() - maven { url "https://maven.google.com" } + google() } dependencies { - classpath 'com.android.tools.build:gradle:3.4.1' - classpath "com.google.gms:google-services:4.2.0" + classpath 'com.android.tools.build:gradle:4.0.1' + classpath "com.google.gms:google-services:4.3.4" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -19,7 +19,7 @@ allprojects { jcenter() maven { url "$rootDir/../node_modules/react-native/android" } maven { url "http://appboy.github.io/appboy-android-sdk/sdk" } - maven { url "https://maven.google.com" } + google() maven { url "$rootDir/../node_modules/jsc-android/dist" } } } diff --git a/AppboyProject/android/gradle/wrapper/gradle-wrapper.properties b/AppboyProject/android/gradle/wrapper/gradle-wrapper.properties index caf54fa..330d844 100644 --- a/AppboyProject/android/gradle/wrapper/gradle-wrapper.properties +++ b/AppboyProject/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Wed Oct 07 15:42:34 EDT 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/AppboyProject/ios/Podfile b/AppboyProject/ios/Podfile index 2559492..73f4f5f 100644 --- a/AppboyProject/ios/Podfile +++ b/AppboyProject/ios/Podfile @@ -2,7 +2,7 @@ platform :ios, '9.0' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' target 'AppboyProject' do - pod 'Appboy-iOS-SDK', '3.27.0' + pod 'Appboy-iOS-SDK', '3.28.0' # If you want to integrate through Cocoapods instead of manual linking use this: # It already comes with a dependency on `Appboy-iOS-SDK` so you're all set. Remember to diff --git a/AppboyProject/ios/Podfile.lock b/AppboyProject/ios/Podfile.lock index 8d6bc32..61e2309 100644 --- a/AppboyProject/ios/Podfile.lock +++ b/AppboyProject/ios/Podfile.lock @@ -1,17 +1,17 @@ PODS: - - Appboy-iOS-SDK (3.27.0): - - Appboy-iOS-SDK/UI (= 3.27.0) - - Appboy-iOS-SDK/ContentCards (3.27.0): + - Appboy-iOS-SDK (3.28.0): + - Appboy-iOS-SDK/UI (= 3.28.0) + - Appboy-iOS-SDK/ContentCards (3.28.0): - Appboy-iOS-SDK/Core - - SDWebImage (~> 5.8.2) - - Appboy-iOS-SDK/Core (3.27.0) - - Appboy-iOS-SDK/InAppMessage (3.27.0): + - SDWebImage (< 6, >= 5.8.2) + - Appboy-iOS-SDK/Core (3.28.0) + - Appboy-iOS-SDK/InAppMessage (3.28.0): - Appboy-iOS-SDK/Core - - SDWebImage (~> 5.8.2) - - Appboy-iOS-SDK/NewsFeed (3.27.0): + - SDWebImage (< 6, >= 5.8.2) + - Appboy-iOS-SDK/NewsFeed (3.28.0): - Appboy-iOS-SDK/Core - - SDWebImage (~> 5.8.2) - - Appboy-iOS-SDK/UI (3.27.0): + - SDWebImage (< 6, >= 5.8.2) + - Appboy-iOS-SDK/UI (3.28.0): - Appboy-iOS-SDK/ContentCards - Appboy-iOS-SDK/Core - Appboy-iOS-SDK/InAppMessage @@ -199,8 +199,8 @@ PODS: - React-cxxreact (= 0.61.5) - React-jsi (= 0.61.5) - React-jsinspector (0.61.5) - - react-native-appboy-sdk (1.23.0): - - Appboy-iOS-SDK (~> 3.27.0) + - react-native-appboy-sdk (1.24.0): + - Appboy-iOS-SDK (~> 3.28.0) - React - React-RCTActionSheet (0.61.5): - React-Core/RCTActionSheetHeaders (= 0.61.5) @@ -237,13 +237,13 @@ PODS: - React-cxxreact (= 0.61.5) - React-jsi (= 0.61.5) - ReactCommon/jscallinvoker (= 0.61.5) - - SDWebImage (5.8.4): - - SDWebImage/Core (= 5.8.4) - - SDWebImage/Core (5.8.4) + - SDWebImage (5.9.2): + - SDWebImage/Core (= 5.9.2) + - SDWebImage/Core (5.9.2) - Yoga (1.14.0) DEPENDENCIES: - - Appboy-iOS-SDK (= 3.27.0) + - Appboy-iOS-SDK (= 3.28.0) - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) - FBReactNativeSpec (from `../node_modules/react-native/Libraries/FBReactNativeSpec`) @@ -336,7 +336,7 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/yoga" SPEC CHECKSUMS: - Appboy-iOS-SDK: bc4f252e271e514bb8e3f12022e0b2a742d127c8 + Appboy-iOS-SDK: 3e4b0de5083514c5e607b08d944457a5ddb5078c boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2 FBLazyVector: aaeaf388755e4f29cd74acbc9e3b8da6d807c37f @@ -352,7 +352,7 @@ SPEC CHECKSUMS: React-jsi: cb2cd74d7ccf4cffb071a46833613edc79cdf8f7 React-jsiexecutor: d5525f9ed5f782fdbacb64b9b01a43a9323d2386 React-jsinspector: fa0ecc501688c3c4c34f28834a76302233e29dc0 - react-native-appboy-sdk: 6fa596751becbe52cacf39256b0bb3d22bb7a1e4 + react-native-appboy-sdk: 2c7f7ea609a3d7f13dfac7d4e8c4cf0211972785 React-RCTActionSheet: 600b4d10e3aea0913b5a92256d2719c0cdd26d76 React-RCTAnimation: 791a87558389c80908ed06cc5dfc5e7920dfa360 React-RCTBlob: d89293cc0236d9cb0933d85e430b0bbe81ad1d72 @@ -363,9 +363,9 @@ SPEC CHECKSUMS: React-RCTText: 9ccc88273e9a3aacff5094d2175a605efa854dbe React-RCTVibration: a49a1f42bf8f5acf1c3e297097517c6b3af377ad ReactCommon: 198c7c8d3591f975e5431bec1b0b3b581aa1c5dd - SDWebImage: cf6922231e95550934da2ada0f20f2becf2ceba9 + SDWebImage: 0b42b8719ab0c5257177d5894306e8a336b21cbb Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b -PODFILE CHECKSUM: 5d77ef703f1ffd20c02607b913d63373a3aeb043 +PODFILE CHECKSUM: 7fc4bd804598d5db218f21952c53199f8268390b COCOAPODS: 1.9.3 diff --git a/AppboyProject/yarn.lock b/AppboyProject/yarn.lock index 74a474c..28627fe 100644 --- a/AppboyProject/yarn.lock +++ b/AppboyProject/yarn.lock @@ -5001,7 +5001,7 @@ react-is@^16.8.1, react-is@^16.8.4, react-is@^16.9.0: integrity sha512-rPCkf/mWBtKc97aLL9/txD8DZdemK0vkA3JMLShjlJB3Pj3s+lpf1KaBzMfQrAmhMQB0n1cU/SUGgKKBCe837Q== "react-native-appboy-sdk@file:..": - version "1.22.0" + version "1.23.0" react-native@^0.61.5: version "0.61.5" diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f899ff..7e90b9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.24.0 + +##### ⚠ Breaking +- Updated the native iOS bridge to [Braze iOS SDK 3.28.0](https://github.com/Appboy/appboy-ios-sdk/blob/master/CHANGELOG.md#3280). +- Updated the native Android bridge to [Braze Android SDK 10.1.0](https://github.com/Appboy/appboy-android-sdk/blob/master/CHANGELOG.md#1010). Please read the Braze Android SDK changelog for details. + ## 1.23.0 ##### ⚠ Breaking diff --git a/android/build.gradle b/android/build.gradle index 360ecba..156ddc4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -17,6 +17,6 @@ android { } dependencies { - api 'com.appboy:android-sdk-ui:8.1.0' + api 'com.appboy:android-sdk-ui:10.1.0' api 'com.facebook.react:react-native:+' } diff --git a/android/src/main/java/com/appboy/reactbridge/AppboyReactBridge.java b/android/src/main/java/com/appboy/reactbridge/AppboyReactBridge.java index da29163..7e49b51 100644 --- a/android/src/main/java/com/appboy/reactbridge/AppboyReactBridge.java +++ b/android/src/main/java/com/appboy/reactbridge/AppboyReactBridge.java @@ -1,24 +1,27 @@ package com.appboy.reactbridge; import android.content.Intent; -import android.util.Log; + +import androidx.annotation.NonNull; import com.appboy.Appboy; +import com.appboy.AppboyUser; +import com.appboy.enums.CardCategory; import com.appboy.enums.Gender; import com.appboy.enums.Month; import com.appboy.enums.NotificationSubscriptionType; -import com.appboy.enums.CardCategory; import com.appboy.events.ContentCardsUpdatedEvent; import com.appboy.events.FeedUpdatedEvent; import com.appboy.events.IEventSubscriber; +import com.appboy.events.SimpleValueCallback; +import com.appboy.models.IInAppMessage; +import com.appboy.models.IInAppMessageImmersive; +import com.appboy.models.MessageButton; import com.appboy.models.cards.BannerImageCard; import com.appboy.models.cards.CaptionedImageCard; import com.appboy.models.cards.Card; import com.appboy.models.cards.ShortNewsCard; import com.appboy.models.cards.TextAnnouncementCard; -import com.appboy.models.IInAppMessage; -import com.appboy.models.IInAppMessageImmersive; -import com.appboy.models.MessageButton; import com.appboy.models.outgoing.AppboyProperties; import com.appboy.models.outgoing.AttributionData; import com.appboy.models.outgoing.FacebookUser; @@ -29,6 +32,7 @@ import com.appboy.ui.activities.AppboyFeedActivity; import com.appboy.ui.inappmessage.AppboyInAppMessageManager; import com.facebook.react.bridge.Arguments; +import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; @@ -37,14 +41,12 @@ import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMapKeySetIterator; import com.facebook.react.bridge.ReadableType; -import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; import com.facebook.react.modules.core.DeviceEventManagerModule; import org.json.JSONObject; -import java.lang.Integer; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; @@ -53,18 +55,17 @@ import java.util.concurrent.ConcurrentHashMap; public class AppboyReactBridge extends ReactContextBaseJavaModule { - private static final String TAG = String.format("Appboy.%s", AppboyReactBridge.class.getName()); + private static final String TAG = AppboyLogger.getAppboyLogTag(AppboyReactBridge.class); private static final String CARD_COUNT_TAG = "card count"; private static final String UNREAD_CARD_COUNT_TAG = "unread card count"; - private static final String DURATION_SHORT_KEY = "SHORT"; - private static final String DURATION_LONG_KEY = "LONG"; private static final String CONTENT_CARDS_UPDATED_EVENT_NAME = "contentCardsUpdated"; + private final Object mCallbackWasCalledMapLock = new Object(); - private IEventSubscriber mContentCardsUpdatedSubscriber; private final List mContentCards = new ArrayList<>(); + private final Map> mFeedSubscriberMap = new ConcurrentHashMap<>(); + private final Map mCallbackWasCalledMap = new ConcurrentHashMap<>(); private long mContentCardsUpdatedAt = 0; - private Map> mFeedSubscriberMap = new ConcurrentHashMap>(); - private Map mCallbackWasCalledMap = new ConcurrentHashMap(); + private IEventSubscriber mContentCardsUpdatedSubscriber; public AppboyReactBridge(ReactApplicationContext reactContext) { super(reactContext); @@ -109,8 +110,13 @@ public void changeUser(String userName) { } @ReactMethod - public void addAlias(String aliasName, String aliasLabel) { - Appboy.getInstance(getReactApplicationContext()).getCurrentUser().addAlias(aliasName, aliasLabel); + public void addAlias(final String aliasName, final String aliasLabel) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + appboyUser.addAlias(aliasName, aliasLabel); + } + }); } @ReactMethod @@ -130,38 +136,46 @@ public void logCustomEvent(String eventName, ReadableMap eventProperties) { private AppboyProperties populateEventPropertiesFromReadableMap(ReadableMap eventProperties) { AppboyProperties properties = new AppboyProperties(); ReadableMapKeySetIterator keySetIterator = eventProperties.keySetIterator(); - if (eventProperties != JSONObject.NULL) { - while (keySetIterator.hasNextKey()) { - String key = keySetIterator.nextKey(); - ReadableType readableType = eventProperties.getType(key); - if (readableType == ReadableType.String) { + if (eventProperties == JSONObject.NULL) { + return properties; + } + + while (keySetIterator.hasNextKey()) { + String key = keySetIterator.nextKey(); + ReadableType readableType = eventProperties.getType(key); + switch (readableType) { + case String: properties.addProperty(key, eventProperties.getString(key)); - } else if (readableType == ReadableType.Boolean) { + break; + case Boolean: properties.addProperty(key, eventProperties.getBoolean(key)); - } else if (readableType == ReadableType.Number) { + break; + case Number: try { properties.addProperty(key, eventProperties.getDouble(key)); } catch (Exception e) { try { properties.addProperty(key, eventProperties.getInt(key)); } catch (Exception e2) { - AppboyLogger.e(TAG, "Could not parse ReadableType.Number from ReadableMap for key: " + key); + AppboyLogger.e(TAG, "Could not parse ReadableType.Number from ReadableMap for key: " + key, e2); } } - } else if (readableType == ReadableType.Map) { + break; + case Map: try { if (eventProperties.getMap(key).getString("type").equals("UNIX_timestamp")) { double unixTimestamp = eventProperties.getMap(key).getDouble("value"); - properties.addProperty(key, new Date((long)unixTimestamp)); + properties.addProperty(key, new Date((long) unixTimestamp)); } else { - AppboyLogger.e(TAG, "Unsupported ReadableMap type received for key: " + key); + AppboyLogger.w(TAG, "Unsupported ReadableMap type received for key: " + key); } } catch (Exception e) { - AppboyLogger.e(TAG, "Could not determine type from ReadableMap for key: " + key); + AppboyLogger.e(TAG, "Could not determine type from ReadableMap for key: " + key, e); } - } else { - AppboyLogger.e(TAG, "Could not map ReadableType to an AppboyProperty value for key: " + key); - } + break; + default: + AppboyLogger.w(TAG, "Could not map ReadableType to an AppboyProperty value for key: " + key); + break; } } return properties; @@ -177,88 +191,153 @@ public void logPurchase(String productIdentifier, String price, String currencyC } @ReactMethod - public void setStringCustomUserAttribute(String key, String value, Callback callback) { - boolean result = Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setCustomUserAttribute(key, value); - reportResultWithCallback(callback, null, result); + public void setStringCustomUserAttribute(final String key, final String value, final Callback callback) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + boolean result = appboyUser.setCustomUserAttribute(key, value); + reportResultWithCallback(callback, null, result); + } + }); } @ReactMethod - public void setBoolCustomUserAttribute(String key, Boolean value, Callback callback) { - boolean result = Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setCustomUserAttribute(key, value); - reportResultWithCallback(callback, null, result); + public void setBoolCustomUserAttribute(final String key, final Boolean value, final Callback callback) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + boolean result = appboyUser.setCustomUserAttribute(key, value); + reportResultWithCallback(callback, null, result); + } + }); } @ReactMethod - public void setIntCustomUserAttribute(String key, int value, Callback callback) { - boolean result = Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setCustomUserAttribute(key, value); - reportResultWithCallback(callback, null, result); + public void setIntCustomUserAttribute(final String key, final int value, final Callback callback) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + boolean result = appboyUser.setCustomUserAttribute(key, value); + reportResultWithCallback(callback, null, result); + } + }); } @ReactMethod - public void setDoubleCustomUserAttribute(String key, float value, Callback callback) { - boolean result = Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setCustomUserAttribute(key, value); - reportResultWithCallback(callback, null, result); + public void setDoubleCustomUserAttribute(final String key, final float value, final Callback callback) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + boolean result = appboyUser.setCustomUserAttribute(key, value); + reportResultWithCallback(callback, null, result); + } + }); } @ReactMethod - public void setDateCustomUserAttribute(String key, int timeStamp, Callback callback) { - boolean result = Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setCustomUserAttributeToSecondsFromEpoch(key, timeStamp); - reportResultWithCallback(callback, null, result); + public void setDateCustomUserAttribute(final String key, final int timeStamp, final Callback callback) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + boolean result = appboyUser.setCustomUserAttributeToSecondsFromEpoch(key, timeStamp); + reportResultWithCallback(callback, null, result); + } + }); } @ReactMethod - public void incrementCustomUserAttribute(String key, int incrementValue, Callback callback) { - boolean result = Appboy.getInstance(getReactApplicationContext()).getCurrentUser().incrementCustomUserAttribute(key, incrementValue); - reportResultWithCallback(callback, null, result); + public void incrementCustomUserAttribute(final String key, final int incrementValue, final Callback callback) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + boolean result = appboyUser.incrementCustomUserAttribute(key, incrementValue); + reportResultWithCallback(callback, null, result); + } + }); } @ReactMethod - public void unsetCustomUserAttribute(String key, Callback callback) { - boolean result = Appboy.getInstance(getReactApplicationContext()).getCurrentUser().unsetCustomUserAttribute(key); - reportResultWithCallback(callback, null, result); + public void unsetCustomUserAttribute(final String key, final Callback callback) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + boolean result = appboyUser.unsetCustomUserAttribute(key); + reportResultWithCallback(callback, null, result); + } + }); } @ReactMethod - public void setCustomUserAttributeArray(String key, ReadableArray value, Callback callback) { + public void setCustomUserAttributeArray(final String key, ReadableArray value, final Callback callback) { int size = value.size(); - String[] attributeArray = new String[size]; + final String[] attributeArray = new String[size]; for (int i = 0; i < size; i++) { attributeArray[i] = value.getString(i); } - boolean result = Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setCustomAttributeArray(key, attributeArray); - reportResultWithCallback(callback, null, result); + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + boolean result = appboyUser.setCustomAttributeArray(key, attributeArray); + reportResultWithCallback(callback, null, result); + } + }); } @ReactMethod - public void addToCustomAttributeArray(String key, String value, Callback callback) { - boolean result = Appboy.getInstance(getReactApplicationContext()).getCurrentUser().addToCustomAttributeArray(key, value); - reportResultWithCallback(callback, null, result); + public void addToCustomAttributeArray(final String key, final String value, final Callback callback) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + boolean result = appboyUser.addToCustomAttributeArray(key, value); + reportResultWithCallback(callback, null, result); + } + }); } @ReactMethod - public void removeFromCustomAttributeArray(String key, String value, Callback callback) { - boolean result = Appboy.getInstance(getReactApplicationContext()).getCurrentUser().removeFromCustomAttributeArray(key, value); - reportResultWithCallback(callback, null, result); + public void removeFromCustomAttributeArray(final String key, final String value, final Callback callback) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + boolean result = appboyUser.removeFromCustomAttributeArray(key, value); + reportResultWithCallback(callback, null, result); + } + }); } @ReactMethod - public void setFirstName(String firstName) { - Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setFirstName(firstName); + public void setFirstName(final String firstName) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + appboyUser.setFirstName(firstName); + } + }); } @ReactMethod - public void setLastName(String lastName) { - Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setLastName(lastName); + public void setLastName(final String lastName) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + appboyUser.setLastName(lastName); + } + }); } @ReactMethod - public void setEmail(String email) { - Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setEmail(email); + public void setEmail(final String email) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + appboyUser.setEmail(email); + } + }); } @ReactMethod - public void setGender(String gender, Callback callback) { - Gender genderEnum; + public void setGender(String gender, final Callback callback) { + final Gender genderEnum; if (gender == null) { reportResultWithCallback(callback, "Input Gender was null. Gender not set.", null); return; @@ -278,43 +357,78 @@ public void setGender(String gender, Callback callback) { reportResultWithCallback(callback, "Invalid input " + gender + ". Gender not set.", null); return; } - boolean result = Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setGender(genderEnum); - reportResultWithCallback(callback, null, result); + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + boolean result = appboyUser.setGender(genderEnum); + reportResultWithCallback(callback, null, result); + } + }); } @ReactMethod - public void setDateOfBirth(int year, int month, int day) { - Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setDateOfBirth(year, parseMonth(month), day); + public void setDateOfBirth(final int year, final int month, final int day) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + appboyUser.setDateOfBirth(year, parseMonth(month), day); + } + }); } @ReactMethod - public void setCountry(String country) { - Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setCountry(country); + public void setCountry(final String country) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + appboyUser.setCountry(country); + } + }); } @ReactMethod - public void setHomeCity(String homeCity) { - Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setHomeCity(homeCity); + public void setHomeCity(final String homeCity) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + appboyUser.setHomeCity(homeCity); + } + }); } @ReactMethod - public void setPhoneNumber(String phoneNumber) { - Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setPhoneNumber(phoneNumber); + public void setPhoneNumber(final String phoneNumber) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + appboyUser.setPhoneNumber(phoneNumber); + } + }); } @ReactMethod - public void setLanguage(String language) { - Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setLanguage(language); + public void setLanguage(final String language) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + appboyUser.setLanguage(language); + } + }); } @ReactMethod - public void setAvatarImageUrl(String avatarImageUrl) { - Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setAvatarImageUrl(avatarImageUrl); + public void setAvatarImageUrl(final String avatarImageUrl) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + appboyUser.setAvatarImageUrl(avatarImageUrl); + } + }); } @ReactMethod - public void setPushNotificationSubscriptionType(String subscriptionType, Callback callback) { - NotificationSubscriptionType notificationSubscriptionType; + public void setPushNotificationSubscriptionType(String subscriptionType, final Callback callback) { + final NotificationSubscriptionType notificationSubscriptionType; if (subscriptionType == null) { reportResultWithCallback(callback, "Input subscription type was null. Push notification subscription type not set.", null); return; @@ -328,13 +442,18 @@ public void setPushNotificationSubscriptionType(String subscriptionType, Callbac reportResultWithCallback(callback, "Invalid subscription type " + subscriptionType + ". Push notification subscription type not set.", null); return; } - boolean result = Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setPushNotificationSubscriptionType(notificationSubscriptionType); - reportResultWithCallback(callback, null, result); + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + boolean result = appboyUser.setPushNotificationSubscriptionType(notificationSubscriptionType); + reportResultWithCallback(callback, null, result); + } + }); } @ReactMethod - public void setEmailNotificationSubscriptionType(String subscriptionType, Callback callback) { - NotificationSubscriptionType notificationSubscriptionType; + public void setEmailNotificationSubscriptionType(String subscriptionType, final Callback callback) { + final NotificationSubscriptionType notificationSubscriptionType; if (subscriptionType == null) { reportResultWithCallback(callback, "Input subscription type was null. Email notification subscription type not set.", null); return; @@ -348,14 +467,38 @@ public void setEmailNotificationSubscriptionType(String subscriptionType, Callba reportResultWithCallback(callback, "Invalid subscription type " + subscriptionType + ". Email notification subscription type not set.", null); return; } - boolean result = Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setEmailNotificationSubscriptionType(notificationSubscriptionType); - reportResultWithCallback(callback, null, result); - } - - @ReactMethod - public void setTwitterData(Integer id, String screenName, String name, String description, Integer followersCount, Integer friendsCount, Integer statusesCount, String profileImageUrl) { - TwitterUser twitterUser = new TwitterUser(id, screenName, name, description, followersCount, friendsCount, statusesCount, profileImageUrl); - Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setTwitterData(twitterUser); + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + boolean result = appboyUser.setEmailNotificationSubscriptionType(notificationSubscriptionType); + reportResultWithCallback(callback, null, result); + } + }); + } + + @ReactMethod + public void setTwitterData(Integer id, + String screenName, + String name, + String description, + Integer followersCount, + Integer friendsCount, + Integer statusesCount, + String profileImageUrl) { + final TwitterUser twitterUser = new TwitterUser(id, + screenName, + name, + description, + followersCount, + friendsCount, + statusesCount, + profileImageUrl); + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + appboyUser.setTwitterData(twitterUser); + } + }); } @ReactMethod @@ -406,9 +549,14 @@ public void setFacebookData(ReadableMap facebookUserDictionary, Integer numberOf cityName = location.getString("name"); } } - FacebookUser facebookUser = new FacebookUser(facebookId, firstName, lastName, email, + final FacebookUser facebookUser = new FacebookUser(facebookId, firstName, lastName, email, bio, cityName, genderEnum, numberOfFriends, likesList, birthday); - Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setFacebookData(facebookUser); + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + appboyUser.setFacebookData(facebookUser); + } + }); } @ReactMethod @@ -626,50 +774,53 @@ private void getCardCountForTag(final String category, final Callback callback, IEventSubscriber feedUpdatedSubscriber = null; boolean requestingFeedUpdateFromCache = false; - if (cardCountTag.equals(CARD_COUNT_TAG)) { - // getCardCount - feedUpdatedSubscriber = new IEventSubscriber() { - @Override - public void trigger(FeedUpdatedEvent feedUpdatedEvent) { - // Callback blocks (error or result) may only be invoked once, else React Native throws an error. - synchronized (mCallbackWasCalledMapLock) { - if (mCallbackWasCalledMap.get(callback) == null || mCallbackWasCalledMap.get(callback) != null && !mCallbackWasCalledMap.get(callback).booleanValue()) { - mCallbackWasCalledMap.put(callback, new Boolean(true)); - if (category.equals("all")) { - reportResultWithCallback(callback, null, feedUpdatedEvent.getCardCount()); - } else { - reportResultWithCallback(callback, null, feedUpdatedEvent.getCardCount(cardCategory)); + switch (cardCountTag) { + case CARD_COUNT_TAG: + // getCardCount + feedUpdatedSubscriber = new IEventSubscriber() { + @Override + public void trigger(FeedUpdatedEvent feedUpdatedEvent) { + // Callback blocks (error or result) may only be invoked once, else React Native throws an error. + synchronized (mCallbackWasCalledMapLock) { + if (mCallbackWasCalledMap.get(callback) == null || mCallbackWasCalledMap.get(callback) != null && !mCallbackWasCalledMap.get(callback).booleanValue()) { + mCallbackWasCalledMap.put(callback, new Boolean(true)); + if (category.equals("all")) { + reportResultWithCallback(callback, null, feedUpdatedEvent.getCardCount()); + } else { + reportResultWithCallback(callback, null, feedUpdatedEvent.getCardCount(cardCategory)); + } } } + // Remove this listener from the feed subscriber map and from Appboy + Appboy.getInstance(getReactApplicationContext()).removeSingleSubscription(mFeedSubscriberMap.get(callback), FeedUpdatedEvent.class); + mFeedSubscriberMap.remove(callback); } - // Remove this listener from the feed subscriber map and from Appboy - Appboy.getInstance(getReactApplicationContext()).removeSingleSubscription(mFeedSubscriberMap.get(callback), FeedUpdatedEvent.class); - mFeedSubscriberMap.remove(callback); - } - }; - requestingFeedUpdateFromCache = true; - } else if (cardCountTag.equals(UNREAD_CARD_COUNT_TAG)) { - // getUnreadCardCount - feedUpdatedSubscriber = new IEventSubscriber() { - @Override - public void trigger(FeedUpdatedEvent feedUpdatedEvent) { - // Callback blocks (error or result) may only be invoked once, else React Native throws an error. - synchronized (mCallbackWasCalledMapLock) { - if (mCallbackWasCalledMap.get(callback) == null || mCallbackWasCalledMap.get(callback)!= null && !mCallbackWasCalledMap.get(callback).booleanValue()) { - mCallbackWasCalledMap.put(callback, new Boolean(true)); - if (category.equals("all")) { - reportResultWithCallback(callback, null, feedUpdatedEvent.getUnreadCardCount()); - } else { - reportResultWithCallback(callback, null, feedUpdatedEvent.getUnreadCardCount(cardCategory)); + }; + requestingFeedUpdateFromCache = true; + break; + case UNREAD_CARD_COUNT_TAG: + // getUnreadCardCount + feedUpdatedSubscriber = new IEventSubscriber() { + @Override + public void trigger(FeedUpdatedEvent feedUpdatedEvent) { + // Callback blocks (error or result) may only be invoked once, else React Native throws an error. + synchronized (mCallbackWasCalledMapLock) { + if (mCallbackWasCalledMap.get(callback) == null || mCallbackWasCalledMap.get(callback) != null && !mCallbackWasCalledMap.get(callback).booleanValue()) { + mCallbackWasCalledMap.put(callback, new Boolean(true)); + if (category.equals("all")) { + reportResultWithCallback(callback, null, feedUpdatedEvent.getUnreadCardCount()); + } else { + reportResultWithCallback(callback, null, feedUpdatedEvent.getUnreadCardCount(cardCategory)); + } } } + // Remove this listener from the feed subscriber map and from Appboy + Appboy.getInstance(getReactApplicationContext()).removeSingleSubscription(mFeedSubscriberMap.get(callback), FeedUpdatedEvent.class); + mFeedSubscriberMap.remove(callback); } - // Remove this listener from the feed subscriber map and from Appboy - Appboy.getInstance(getReactApplicationContext()).removeSingleSubscription(mFeedSubscriberMap.get(callback), FeedUpdatedEvent.class); - mFeedSubscriberMap.remove(callback); - } - }; - requestingFeedUpdateFromCache = true; + }; + requestingFeedUpdateFromCache = true; + break; } if (requestingFeedUpdateFromCache) { @@ -716,10 +867,15 @@ public void requestGeofences(Double latitude, Double longitude) { } @ReactMethod - public void setLocationCustomAttribute(String key, Double latitude, Double longitude, Callback callback) { - Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setLocationCustomAttribute(key, latitude, longitude); - // Always return true as Android doesn't support getting a result from setLocationCustomAttribute(). - reportResultWithCallback(callback, null, true); + public void setLocationCustomAttribute(final String key, final Double latitude, final Double longitude, final Callback callback) { + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + appboyUser.setLocationCustomAttribute(key, latitude, longitude); + // Always return true as Android doesn't support getting a result from setLocationCustomAttribute(). + reportResultWithCallback(callback, null, true); + } + }); } @ReactMethod @@ -759,8 +915,13 @@ public void logInAppMessageButtonClicked(String inAppMessageString, Integer butt @ReactMethod public void setAttributionData(String network, String campaign, String adGroup, String creative) { - AttributionData attributionData = new AttributionData(network, campaign, adGroup, creative); - Appboy.getInstance(getReactApplicationContext()).getCurrentUser().setAttributionData(attributionData); + final AttributionData attributionData = new AttributionData(network, campaign, adGroup, creative); + Appboy.getInstance(getReactApplicationContext()).getCurrentUser(new SimpleValueCallback() { + @Override + public void onSuccess(@NonNull AppboyUser appboyUser) { + appboyUser.setAttributionData(attributionData); + } + }); } @ReactMethod diff --git a/android/src/main/java/com/appboy/reactbridge/AppboyReactPackage.java b/android/src/main/java/com/appboy/reactbridge/AppboyReactPackage.java index 62dfd6f..0c18c87 100644 --- a/android/src/main/java/com/appboy/reactbridge/AppboyReactPackage.java +++ b/android/src/main/java/com/appboy/reactbridge/AppboyReactPackage.java @@ -1,20 +1,21 @@ package com.appboy.reactbridge; +import androidx.annotation.NonNull; + import com.facebook.react.ReactPackage; import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.ViewManager; + import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; public class AppboyReactPackage implements ReactPackage { @Override - public List createNativeModules( - ReactApplicationContext reactContext) { + public List createNativeModules(@NonNull ReactApplicationContext reactContext) { List modules = new ArrayList<>(); modules.add(new AppboyReactBridge(reactContext)); @@ -28,7 +29,7 @@ public List> createJSModules() { } @Override - public List createViewManagers(ReactApplicationContext reactContext) { - return Arrays.asList(); + public List createViewManagers(@NonNull ReactApplicationContext reactContext) { + return Collections.emptyList(); } } diff --git a/package.json b/package.json index 36adf49..03048c5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-appboy-sdk", - "version": "1.23.0", + "version": "1.24.0", "description": "Braze SDK for React Native.", "main": "index.js", "types": "index.d.ts", diff --git a/react-native-appboy-sdk.podspec b/react-native-appboy-sdk.podspec index adc401e..7bdb412 100644 --- a/react-native-appboy-sdk.podspec +++ b/react-native-appboy-sdk.podspec @@ -18,6 +18,6 @@ Pod::Spec.new do |s| s.preserve_paths = 'LICENSE.md', 'README.md', 'package.json', 'index.js' s.source_files = 'iOS/**/*.{h,m}' - s.dependency 'Appboy-iOS-SDK', '~> 3.27.0' + s.dependency 'Appboy-iOS-SDK', '~> 3.28.0' s.dependency 'React' end