Skip to content

Commit

Permalink
Release version 1.31.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyorbin committed Jul 23, 2021
1 parent ae4ee21 commit 3b28abf
Show file tree
Hide file tree
Showing 13 changed files with 140 additions and 30 deletions.
23 changes: 22 additions & 1 deletion AppboyProject/AppboyProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class AppboyProject extends Component {
super(props);
this.state = {
userIdText : '',
signatureText: '',
customEventText : '',
subscriptionState : 's',
gender : 'm',
Expand All @@ -30,6 +31,7 @@ class AppboyProject extends Component {
this._getInstallTrackingId = this._getInstallTrackingId.bind(this);
this._updateCardCount = this._updateCardCount.bind(this);
this._changeUserPress = this._changeUserPress.bind(this);
this._setSignaturePress = this._setSignaturePress.bind(this);
this._logCustomEventPress = this._logCustomEventPress.bind(this);
this._setSubscriptionStatePress = this._setSubscriptionStatePress.bind(this);
this._logPurchasePress = this._logPurchasePress.bind(this);
Expand Down Expand Up @@ -88,7 +90,11 @@ class AppboyProject extends Component {

ReactAppboy.addListener(ReactAppboy.Events.CONTENT_CARDS_UPDATED, function() {
console.log('Content Cards Updated.');
})
});

ReactAppboy.addListener(ReactAppboy.Events.SDK_AUTHENTICATION_ERROR, function(data) {
console.log(`SDK Authentication for ${data.user_id} failed with error code ${data.error_code}.`);
});

this._listener = DeviceEventEmitter.addListener("inAppMessageReceived", function(event) {
let inAppMessage = new ReactAppboy.BrazeInAppMessage(event.inAppMessage);
Expand Down Expand Up @@ -156,6 +162,17 @@ class AppboyProject extends Component {
<Text>Set User ID</Text>
</TouchableHighlight>
</View>
<View style={styles.row}>
<TextInput
style={styles.textInput}
onChangeText={(signatureText) => this.setState({signatureText})}
value={this.state.signatureText}
/>
<TouchableHighlight
onPress={this._setSignaturePress}>
<Text>Set Signature</Text>
</TouchableHighlight>
</View>
<View style={styles.row}>
<TextInput
style={styles.textInput}
Expand Down Expand Up @@ -325,6 +342,10 @@ class AppboyProject extends Component {
ReactAppboy.changeUser(this.state.userIdText);
this._showToast('User changed to: ' + this.state.userIdText);
}
_setSignaturePress(event) {
ReactAppboy.setSdkAuthenticationSignature(this.state.signatureText);
this._showToast('Signature set to: ' + this.state.signatureText);
}
_logCustomEventPress(event) {
var testDate = new Date();
ReactAppboy.logCustomEvent(this.state.customEventText, {'stringKey': 'stringValue', 'intKey': 42, 'floatKey': 1.23, 'boolKey': true, 'dateKey': testDate});
Expand Down
8 changes: 2 additions & 6 deletions AppboyProject/ios/AppboyProject.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AppboyProject/AppboyProject.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer: Appboy Appboy (QWFN3H2ZPW)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Appboy Appboy (QWFN3H2ZPW)";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
Expand Down Expand Up @@ -578,8 +577,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AppboyProject/AppboyProject.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution: Appboy Inc. (5GLZKGNWQ3)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 5GLZKGNWQ3;
Expand Down Expand Up @@ -724,7 +722,6 @@
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -765,7 +762,6 @@
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down
2 changes: 1 addition & 1 deletion AppboyProject/ios/AppboyProject/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string></string>
<key>CFBundleDisplayName</key>
<string></string>
<key>Appboy</key>
<key>Braze</key>
<dict>
<key>LogLevel</key>
<string>0</string>
Expand Down
21 changes: 21 additions & 0 deletions AppboyProject/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,25 @@ target 'AppboyProject' do
end

use_native_modules!

# Fix for XCode 12.5 (see: https://github.com/facebook/react-native/issues/31480)
post_install do |installer|
find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
"_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
"RCTBridgeModuleNameForClass(module))", "RCTBridgeModuleNameForClass(Class(module)))")
end

def find_and_replace(dir, findstr, replacestr)
Dir[dir].each do |name|
text = File.read(name)
replace = text.gsub(findstr,replacestr)
if text != replace
puts "Fix: " + name
File.open(name, "w") { |file| file.puts replace }
STDOUT.flush
end
end
Dir[dir + '*/'].each(&method(:find_and_replace))
end
end
24 changes: 12 additions & 12 deletions AppboyProject/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
PODS:
- Appboy-iOS-SDK (4.3.0):
- Appboy-iOS-SDK/UI (= 4.3.0)
- Appboy-iOS-SDK/ContentCards (4.3.0):
- Appboy-iOS-SDK (4.3.1):
- Appboy-iOS-SDK/UI (= 4.3.1)
- Appboy-iOS-SDK/ContentCards (4.3.1):
- Appboy-iOS-SDK/Core
- SDWebImage (< 6, >= 5.8.2)
- Appboy-iOS-SDK/Core (4.3.0)
- Appboy-iOS-SDK/InAppMessage (4.3.0):
- Appboy-iOS-SDK/Core (4.3.1)
- Appboy-iOS-SDK/InAppMessage (4.3.1):
- Appboy-iOS-SDK/Core
- SDWebImage (< 6, >= 5.8.2)
- Appboy-iOS-SDK/NewsFeed (4.3.0):
- Appboy-iOS-SDK/NewsFeed (4.3.1):
- Appboy-iOS-SDK/Core
- SDWebImage (< 6, >= 5.8.2)
- Appboy-iOS-SDK/UI (4.3.0):
- Appboy-iOS-SDK/UI (4.3.1):
- Appboy-iOS-SDK/ContentCards
- Appboy-iOS-SDK/Core
- Appboy-iOS-SDK/InAppMessage
Expand Down Expand Up @@ -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.30.0):
- Appboy-iOS-SDK (~> 4.3.0)
- react-native-appboy-sdk (1.31.0):
- Appboy-iOS-SDK (~> 4.3.1)
- React
- React-RCTActionSheet (0.61.5):
- React-Core/RCTActionSheetHeaders (= 0.61.5)
Expand Down Expand Up @@ -334,7 +334,7 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/yoga"

SPEC CHECKSUMS:
Appboy-iOS-SDK: dade18b2f6dc5c058669367c558ed87f389e4eea
Appboy-iOS-SDK: 33b31d5ade91a7d0718534798f4ab1146e7b0681
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2
FBLazyVector: aaeaf388755e4f29cd74acbc9e3b8da6d807c37f
Expand All @@ -350,7 +350,7 @@ SPEC CHECKSUMS:
React-jsi: cb2cd74d7ccf4cffb071a46833613edc79cdf8f7
React-jsiexecutor: d5525f9ed5f782fdbacb64b9b01a43a9323d2386
React-jsinspector: fa0ecc501688c3c4c34f28834a76302233e29dc0
react-native-appboy-sdk: dd0f7fb390666c6cfea7e177dcf22c3391e9cc39
react-native-appboy-sdk: 211e9e77ad5e523191c3cddd0252056668b45a13
React-RCTActionSheet: 600b4d10e3aea0913b5a92256d2719c0cdd26d76
React-RCTAnimation: 791a87558389c80908ed06cc5dfc5e7920dfa360
React-RCTBlob: d89293cc0236d9cb0933d85e430b0bbe81ad1d72
Expand All @@ -364,6 +364,6 @@ SPEC CHECKSUMS:
SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d
Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b

PODFILE CHECKSUM: 5e38fbb08cd1a275383326ec8003103e6721fdc2
PODFILE CHECKSUM: 12f4fef8b6ce7354bd8698dc795dfb0568db600d

COCOAPODS: 1.10.1
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.31.0

##### ⚠ Breaking
- Updated the native iOS bridge to [Braze iOS SDK 4.3.1](https://github.com/Appboy/appboy-ios-sdk/blob/master/CHANGELOG.md#431).

##### Added
- Added support for new SDK Authentication feature to the Javascript layer. See `setSdkAuthenticationSignature` on the `Appboy` interface, as well as the optional `signature` parameter on `ReactAppboy.changeUser`.

## 1.30.0

##### ⚠ Breaking
Expand Down
11 changes: 9 additions & 2 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jest.mock('NativeModules', () => {
setEmail: jest.fn(),
setPhoneNumber: jest.fn(),
changeUser: jest.fn(),
setSdkAuthenticationSignature: jest.fn(),
setSDKFlavor: jest.fn(),
logCustomEvent: jest.fn(),
logPurchase: jest.fn(),
Expand Down Expand Up @@ -246,7 +247,13 @@ test('it calls AppboyReactBridge.changeUser', () => {
const user_id = "some_id";
ReactAppboy.changeUser(user_id);
expect(NativeModules.AppboyReactBridge.setSDKFlavor).toBeCalled();
expect(NativeModules.AppboyReactBridge.changeUser).toBeCalledWith(user_id);
expect(NativeModules.AppboyReactBridge.changeUser).toBeCalledWith(user_id, null);
});

test('it calls AppboyReactBridge.setSdkAuthenticationSignature', () => {
const signature = "signature";
ReactAppboy.setSdkAuthenticationSignature(signature);
expect(NativeModules.AppboyReactBridge.setSdkAuthenticationSignature).toBeCalledWith(signature);
});

test('it calls AppboyReactBridge.logCustomEvent', () => {
Expand Down Expand Up @@ -595,4 +602,4 @@ it('instantiates a BrazeButton object with the desired defaults', () => {
expect(inAppMessage.text).toBe(defaultText);
expect(inAppMessage.clickAction).toBe(defaultClickAction.toLowerCase());
expect(inAppMessage.id).toBe(defaultId);
});
});
5 changes: 5 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ android {
versionCode 1
versionName '1.0'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
Expand Down
36 changes: 33 additions & 3 deletions iOS/AppboyReactBridge/AppboyReactBridge/AppboyReactBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#import "ABKContentCardsViewController.h"

static NSString *const kContentCardsUpdatedEvent = @"contentCardsUpdated";
static NSString *const kSdkAuthenticationErrorEvent = @"sdkAuthenticationError";

@implementation RCTConvert (AppboySubscriptionType)
RCT_ENUM_CONVERTER(ABKNotificationSubscriptionType,
Expand All @@ -16,6 +17,10 @@ @implementation RCTConvert (AppboySubscriptionType)
integerValue);
@end

@interface AppboyReactBridge () <ABKSdkAuthenticationDelegate>

@end

@implementation AppboyReactBridge {
bool hasListeners;
}
Expand All @@ -35,17 +40,20 @@ - (void)startObserving {
selector:@selector(handleContentCardsUpdated:)
name:ABKContentCardsProcessedNotification
object:nil];
[Appboy sharedInstance].sdkAuthenticationDelegate = self;
}

- (void)stopObserving {
hasListeners = NO;
[[NSNotificationCenter defaultCenter] removeObserver:self];
[Appboy sharedInstance].sdkAuthenticationDelegate = nil;
}

- (NSArray<NSString *> *)supportedEvents {
return @[
kContentCardsUpdatedEvent
];
kContentCardsUpdatedEvent,
kSdkAuthenticationErrorEvent
];

}
- (NSDictionary *)constantsToExport
Expand Down Expand Up @@ -493,7 +501,7 @@ - (ABKCardCategory)getCardCategoryForString:(NSString *)category {

RCT_EXPORT_METHOD(requestImmediateDataFlush) {
RCTLogInfo(@"requestImmediateDataFlush called");
[[Appboy sharedInstance] flushDataAndProcessRequestQueue];
[[Appboy sharedInstance] requestImmediateDataFlush];
}

RCT_EXPORT_METHOD(setLocationCustomAttribute:(NSString *)key latitude:(double)latitude longitude:(double)longitude callback:(RCTResponseSenderBlock)callback) {
Expand Down Expand Up @@ -533,4 +541,26 @@ - (ABKCardCategory)getCardCategoryForString:(NSString *)category {
}

RCT_EXPORT_MODULE();

#pragma mark - SDK Authentication

RCT_EXPORT_METHOD(setSdkAuthenticationSignature:(NSString *)signature)
{
RCTLogInfo(@"[Appboy sharedInstance] setSdkAuthenticationSignature with value %@", signature);
[[Appboy sharedInstance] setSdkAuthenticationSignature:signature];
}

- (void)handleSdkAuthenticationError:(ABKSdkAuthenticationError *)authError {
if (!hasListeners) {
return;
}

NSMutableDictionary *error = [NSMutableDictionary dictionary];
error[@"error_code"] = @(authError.code);
error[@"user_id"] = authError.userId;
error[@"original_signature"] = authError.signature;
error[@"reason"] = authError.reason;
[self sendEventWithName:kSdkAuthenticationErrorEvent body:error];
}

@end
13 changes: 12 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,18 @@ export function getInstallTrackingId(callback: Callback): void;
* to target while logged out and switching back to that user ID as part of your app's logout process.
*
* @param {string} userId - A unique identifier for this user.
* @param {string} signature - An encrypted signature to add to network requests to authenticate the current user. You can update the signature
* using the `setSdkAuthenticationSignature` method. This signature will only have an effect if SDK Authentication is enabled.
*/
export function changeUser(userId: string): void;
export function changeUser(userId: string, signature?: string): void;

/**
* Sets the signature to be used to authenticate the current user. You can also set the signature when calling `changeUser`.
* This signature will only have an effect if SDK Authentication is enabled.
*
* @param signature - The signature to add to network requests to authenticate the current user.
*/
export function setSdkAuthenticationSignature(signature: string): void;

/**
* An alias serves as an alternative unique user identifier. Use aliases to identify users along different
Expand Down Expand Up @@ -631,6 +641,7 @@ export const NotificationSubscriptionTypes : NotificationSubscriptionType;

interface AppboyEvent {
CONTENT_CARDS_UPDATED: 'contentCardsUpdated',
SDK_AUTHENTICATION_ERROR: 'sdkAuthenticationError',
}
export const Events : AppboyEvent;

Expand Down
15 changes: 13 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,21 @@ var ReactAppboy = {
* to target while logged out and switching back to that user ID as part of your app's logout process.
*
* @param {string} userId - A unique identifier for this user.
* @param {string} signature - An optional authentication signature to be used with the SDK Authentication feature.
*/
changeUser: function(userId) {
changeUser: function(userId, signature) {
AppboyReactBridge.setSDKFlavor();
AppboyReactBridge.changeUser(userId, null);
AppboyReactBridge.changeUser(userId, signature != null ? signature : null);
},

/**
* Sets the signature to be used to authenticate the current user. You can also set the signature when calling `changeUser`.
* This signature will only have an effect if SDK Authentication is enabled.
*
* @param signature - The signature to add to network requests to authenticate the current user.
*/
setSdkAuthenticationSignature: function(signature) {
AppboyReactBridge.setSdkAuthenticationSignature(signature);
},

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-appboy-sdk",
"version": "1.30.0",
"version": "1.31.0",
"description": "Braze SDK for React Native.",
"main": "index.js",
"types": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion react-native-appboy-sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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', '~> 4.3.0'
s.dependency 'Appboy-iOS-SDK', '~> 4.3.1'
s.dependency 'React'
end

0 comments on commit 3b28abf

Please sign in to comment.