Skip to content

Commit

Permalink
Release version 13.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vanessaland committed Oct 17, 2024
1 parent b8425ca commit ca6c1f9
Show file tree
Hide file tree
Showing 18 changed files with 313 additions and 126 deletions.
45 changes: 26 additions & 19 deletions BrazeProject/BrazeProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ export const BrazeProject = (): ReactElement => {
]);
};

const handlePushPayload = (pushPayload) => {
if (pushPayload) {
console.log(
`Received push notification payload:
- type: ${pushPayload.payload_type}
- title: ${pushPayload.title}
- is_silent: ${pushPayload.is_silent}
- url: ${pushPayload.url}`,
);
console.log(JSON.stringify(pushPayload, undefined, 2));
}
};

const showToast = (msg: string, duration: number = 2000) => {
setMessage(msg);
setToastVisible(true);
Expand All @@ -177,15 +190,18 @@ export const BrazeProject = (): ReactElement => {
})
.catch(err => console.error('Error getting initial URL', err));

// Handles deep links when an iOS app is launched from hard close via push click.
// Note that this isn't handled by Linking.getInitialURL(), as the app is
// launched not from a deep link, but from clicking on the push notification.
// For more detail, see `Braze.getInitialURL` in `index.js`.
Braze.getInitialURL(url => {
if (url) {
console.log('Braze.getInitialURL is ' + url);
showToast('Braze.getInitialURL is ' + url);
handleOpenUrl({ url });
// Handles push notification payloads and deep links when an iOS app is launched from terminated state via push click.
// For more detail, see `Braze.getInitialPushPayload`.
Braze.getInitialPushPayload(pushPayload => {
if (pushPayload) {
handlePushPayload(pushPayload);

// If the push payload contains a URL, handle it
let initialURL = pushPayload.url;
if (initialURL) {
showToast('Initial URL is: ' + initialURL);
handleOpenUrl({ url: initialURL });
}
}
});

Expand Down Expand Up @@ -242,16 +258,7 @@ export const BrazeProject = (): ReactElement => {

const pushEventSubscription = Braze.addListener(
Braze.Events.PUSH_NOTIFICATION_EVENT,
function (data) {
console.log(
`Push notification subscription triggered:
- type: ${data.payload_type}
- title: ${data.title}
- is_silent: ${data.is_silent}
`,
);
console.log(JSON.stringify(data, undefined, 2));
},
data => handlePushPayload(data),
);

return () => {
Expand Down
12 changes: 10 additions & 2 deletions BrazeProject/ios/BrazeProject/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
#import <BrazeKit/BrazeKit-Swift.h>
#import "BrazeReactGIFHelper.h"

@interface AppDelegate ()

// Keep a strong reference to the BrazeDelegate to ensure it is not deallocated.
@property (nonatomic, strong) BrazeReactDelegate *brazeDelegate;

@end

@implementation AppDelegate

static Braze *_braze;
Expand Down Expand Up @@ -45,7 +52,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}

Braze *braze = [BrazeReactBridge initBraze:configuration];
braze.delegate = [[BrazeReactDelegate alloc] init];
self.brazeDelegate = [[BrazeReactDelegate alloc] init];
braze.delegate = self.brazeDelegate;
AppDelegate.braze = braze;

// Use SDWebImage as the GIF provider.
Expand All @@ -58,7 +66,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[self registerForPushNotifications];
}

[[BrazeReactUtils sharedInstance] populateInitialUrlFromLaunchOptions:launchOptions];
[[BrazeReactUtils sharedInstance] populateInitialPayloadFromLaunchOptions:launchOptions];

return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
Expand Down
4 changes: 2 additions & 2 deletions BrazeProject/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ target 'BrazeProject' do
end

target 'BrazeProjectRichPush' do
pod 'BrazeNotificationService', '~> 11.0.0'
pod 'BrazeNotificationService', '~> 11.1.1'
end

target 'BrazeProjectPushStory' do
pod 'BrazePushStory', '~> 11.0.0'
pod 'BrazePushStory', '~> 11.1.1'
end
44 changes: 22 additions & 22 deletions BrazeProject/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
PODS:
- boost (1.84.0)
- braze-react-native-sdk (13.0.0):
- BrazeKit (~> 11.0.0)
- BrazeLocation (~> 11.0.0)
- BrazeUI (~> 11.0.0)
- braze-react-native-sdk (13.1.0):
- BrazeKit (~> 11.1.1)
- BrazeLocation (~> 11.1.1)
- BrazeUI (~> 11.1.1)
- DoubleConversion
- glog
- hermes-engine
Expand All @@ -24,13 +24,13 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- BrazeKit (11.0.0)
- BrazeLocation (11.0.0):
- BrazeKit (= 11.0.0)
- BrazeNotificationService (11.0.0)
- BrazePushStory (11.0.0)
- BrazeUI (11.0.0):
- BrazeKit (= 11.0.0)
- BrazeKit (11.1.1)
- BrazeLocation (11.1.1):
- BrazeKit (= 11.1.1)
- BrazeNotificationService (11.1.1)
- BrazePushStory (11.1.1)
- BrazeUI (11.1.1):
- BrazeKit (= 11.1.1)
- DoubleConversion (1.1.6)
- FBLazyVector (0.75.2)
- fmt (9.1.0)
Expand Down Expand Up @@ -1537,8 +1537,8 @@ PODS:
DEPENDENCIES:
- boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)
- "braze-react-native-sdk (from `../node_modules/@braze/react-native-sdk`)"
- BrazeNotificationService (~> 11.0.0)
- BrazePushStory (~> 11.0.0)
- BrazeNotificationService (~> 11.1.1)
- BrazePushStory (~> 11.1.1)
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
- fmt (from `../node_modules/react-native/third-party-podspecs/fmt.podspec`)
Expand Down Expand Up @@ -1745,18 +1745,18 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost: 4cb898d0bf20404aab1850c656dcea009429d6c1
braze-react-native-sdk: 86de16e215b6c75d31a825c98052732108145412
BrazeKit: eeef52b04bef0b5754c9cee6cae2db0021246b87
BrazeLocation: f48cf3bec07a085e45b82026ac960671fa93ac46
BrazeNotificationService: 3b5d374891ad4d61e8e5a816594681fc5d218a7c
BrazePushStory: c1520c52e51c29d261bbd29edcee81b376ede401
BrazeUI: 5dd1f6598fb4b32449d69c0139dd86c320e3651d
braze-react-native-sdk: bc78ee374951dd88e9b916c53112d920f4696777
BrazeKit: 879da791a0f4e247846a06c6de95f8b93f4579df
BrazeLocation: 59af48eafcf233a8ef16de3f6900955332113fe4
BrazeNotificationService: 4e082e73a7b2ed8aa1488a1f9d9177e1051ea4b2
BrazePushStory: eb83b837c290136c06d891d1d430acc02ca40ec1
BrazeUI: 0785c09df3cc03aa6374ac3307215caef7e49bd3
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
FBLazyVector: 38bb611218305c3bc61803e287b8a81c6f63b619
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
glog: 69ef571f3de08433d766d614c73a9838a06bf7eb
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
hermes-engine: 3b6e0717ca847e2fc90a201e59db36caf04dee88
RCT-Folly: 4464f4d875961fce86008d45f4ecf6cef6de0740
RCT-Folly: 02617c592a293bd6d418e0a88ff4ee1f88329b47
RCTDeprecation: 34cbf122b623037ea9facad2e92e53434c5c7422
RCTRequired: 24c446d7bcd0f517d516b6265d8df04dc3eb1219
RCTTypeSafety: ef5e91bd791abd3a99b2c75fd565791102a66352
Expand Down Expand Up @@ -1815,6 +1815,6 @@ SPEC CHECKSUMS:
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: a1d7895431387402a674fd0d1c04ec85e87909b8

PODFILE CHECKSUM: 9d2830ef3c0cbe5823ce11c186bdb0a5f1b78514
PODFILE CHECKSUM: d2de0a300a100d6e4a0f6663ec3607c40a5251fd

COCOAPODS: 1.15.2
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
⚠️ In version 2.0.0, we changed the iOS bridge from AppboyKit, which is written in Objective-C, to the new [Swift SDK](https://github.com/braze-inc/braze-swift-sdk). If you are upgrading from a version below 2.0.0 to a version above 2.0.0, please read [the instructions](https://github.com/braze-inc/braze-react-native-sdk/blob/master/CHANGELOG.md#200) to ensure a smooth transition and backward compatibility.

## 13.1.0

##### Fixed
- Updates the iOS sample app to properly retain the `BrazeReactDelegate` instance. Internally, the Braze SDK uses a weak reference to the delegate, which could be deallocated if not retained by the app. This change ensures the delegate is retained for the lifecycle of the app.

##### Added
- Updates the native iOS version bindings [from Braze Swift SDK 11.0.0 to 11.1.1](https://github.com/braze-inc/braze-swift-sdk/compare/11.0.0...11.1.1#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed).
- Adds the method `Braze.getInitialPushPayload()` to get the push notification payload when opening the app via notification click while the application was in a terminated state.
- `Braze.getInitialURL()` is now deprecated in favor of `Braze.getInitialPushPayload()`. To access the initial URL, use the new method to receive the push notification payload, and access the value of the `url` key.
- If you are using `Braze.getInitialPushPayload()`, add the following code to your `application:didFinishLaunchingWithOptions:launchOptions:`:
```
[[BrazeReactUtils sharedInstance] populateInitialPayloadFromLaunchOptions:launchOptions];
```
This replaces `populateInitialUrlFromLaunchOptions`, which is now deprecated.

## 13.0.0

⚠️ **Important:** This version includes a Swift SDK version with a known issue related to push subscription status. Upgrade to version `13.1.0` instead.

##### Breaking
- Updates the native Android version bindings [from Braze Android SDK 31.1.0 to 32.1.0](https://github.com/braze-inc/braze-android-sdk/compare/v31.1.0...v32.1.0#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed).
- Updates the native iOS version bindings [from Braze Swift SDK 10.3.0 to 11.0.0](https://github.com/braze-inc/braze-swift-sdk/compare/10.3.0...11.0.0#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed).
Expand Down
53 changes: 51 additions & 2 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ const testCallback = jest.fn();

const testInAppMessageJson = `{\"message\":\"body body\",\"type\":\"MODAL\",\"text_align_message\":\"CENTER\",\"click_action\":\"NONE\",\"message_close\":\"SWIPE\",\"extras\":{\"test\":\"123\",\"foo\":\"bar\"},\"header\":\"hello\",\"text_align_header\":\"CENTER\",\"image_url\":\"https:\\/\\/github.com\\/braze-inc\\/braze-react-native-sdk\\/blob\\/master\\/.github\\/assets\\/logo-dark.png?raw=true\",\"image_style\":\"TOP\",\"btns\":[{\"id\":0,\"text\":\"button 1\",\"click_action\":\"URI\",\"uri\":\"https:\\/\\/www.google.com\",\"use_webview\":true,\"bg_color\":4294967295,\"text_color\":4279990479,\"border_color\":4279990479},{\"id\":1,\"text\":\"button 2\",\"click_action\":\"NONE\",\"bg_color\":4279990479,\"text_color\":4294967295,\"border_color\":4279990479}],\"close_btn_color\":4291085508,\"bg_color\":4294243575,\"frame_color\":3207803699,\"text_color\":4280624421,\"header_text_color\":4280624421,\"trigger_id\":\"NWJhNTMxOThiZjVjZWE0NDZiMTUzYjZiXyRfbXY9NWJhNTMxOThiZjVjZWE0NDZiMTUzYjc1JnBpPWNtcA==\", \"is_test_send\":false}`;

const testPushPayloadJson = {
"use_webview": false,
"is_silent": false,
"ios": {
"aps": {
"alert": {
"title": "Test Message",
"body": "Hello World"
},
"interruption-level": "active"
},
"action_identifier": "com.apple.UNNotificationDefaultActionIdentifier"
},
"payload_type": "push_opened",
"title": "Test Message",
"braze_properties": {},
"is_braze_internal": false,
"body": "Hello World",
"timestamp": 1728060077,
"url": "www.braze.com"
};

afterEach(() => {
jest.clearAllMocks();
});
Expand Down Expand Up @@ -470,11 +492,20 @@ test('it calls BrazeReactBridge.getUnreadCardCountForCategories', () => {

test('it calls BrazeReactBridge.getInitialURL if defined', () => {
NativeBrazeReactModule.getInitialURL.mockImplementation((callback) => {
callback(null, "some_data");
callback(null, testPushPayloadJson["url"]);
});
Braze.getInitialURL(testCallback);
expect(NativeBrazeReactModule.getInitialURL).toBeCalled();
expect(testCallback).toBeCalledWith("some_data");
expect(testCallback).toBeCalledWith(testPushPayloadJson["url"]);
});

test('it calls BrazeReactBridge.getInitialPushPayload if defined', () => {
NativeBrazeReactModule.getInitialPushPayload.mockImplementation((callback) => {
callback(null, testPushPayloadJson);
});
Braze.getInitialPushPayload(testCallback);
expect(NativeBrazeReactModule.getInitialPushPayload).toBeCalled();
expect(testCallback).toBeCalledWith(testPushPayloadJson);
});

test('it calls BrazeReactBridge.getDeviceId', () => {
Expand All @@ -496,6 +527,16 @@ test('it calls the callback with null and logs the error if BrazeReactBridge.get
expect(console.log).toBeCalledWith("error");
});

test('it calls the callback with null and logs the error if BrazeReactBridge.getInitialPushPayload returns an error', () => {
NativeBrazeReactModule.getInitialPushPayload.mockImplementation((callback) => {
callback("error", null);
});
Braze.getInitialPushPayload(testCallback);
expect(NativeBrazeReactModule.getInitialPushPayload).toBeCalled();
expect(testCallback).toBeCalledWith(null);
expect(console.log).toBeCalledWith("error");
});

test('it calls the callback with null if BrazeReactBridge.getInitialUrl is running on Android', () => {
const platform = Platform.OS;
Platform.OS = 'android';
Expand All @@ -504,6 +545,14 @@ test('it calls the callback with null if BrazeReactBridge.getInitialUrl is runni
Platform.OS = platform;
});

test('it calls the callback with null if BrazeReactBridge.getInitialPushPayload is running on Android', () => {
const platform = Platform.OS;
Platform.OS = 'android';
Braze.getInitialPushPayload(testCallback);
expect(testCallback).toBeCalledWith(null);
Platform.OS = platform;
});

test('it calls BrazeReactBridge.subscribeToInAppMessage', () => {
Braze.subscribeToInAppMessage(true, testCallback);
expect(NativeBrazeReactModule.subscribeToInAppMessage).toBeCalledWith(true, testCallback);
Expand Down
1 change: 1 addition & 0 deletions __tests__/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jest.mock('react-native/Libraries/TurboModule/TurboModuleRegistry', () => {
getCardCountForCategories: jest.fn(),
getUnreadCardCountForCategories: jest.fn(),
getInitialURL: jest.fn(),
getInitialPushPayload: jest.fn(),
getDeviceId: jest.fn(),
requestLocationInitialization: jest.fn(),
requestGeofences: jest.fn(),
Expand Down
4 changes: 4 additions & 0 deletions android/src/newarch/com/braze/reactbridge/BrazeReactBridge.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class BrazeReactBridge(reactContext: ReactApplicationContext): NativeBrazeReactM
// iOS only
}

override fun getInitialPushPayload(callback: Callback) {
// iOS only
}

override fun getDeviceId(callback: Callback) {
return brazeImpl.getDeviceId(callback)
}
Expand Down
5 changes: 5 additions & 0 deletions android/src/oldarch/com/braze/reactbridge/BrazeReactBridge.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class BrazeReactBridge(reactContext: ReactApplicationContext?) : ReactContextBas
// iOS only
}

@ReactMethod
fun getInitialPushPayload(callback: Callback) {
// iOS only
}

@ReactMethod
fun getDeviceId(callback: Callback) {
return brazeImpl.getDeviceId(callback)
Expand Down
6 changes: 3 additions & 3 deletions braze-react-native-sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Pod::Spec.new do |s|

install_modules_dependencies(s)

s.dependency 'BrazeKit', '~> 11.0.0'
s.dependency 'BrazeLocation', '~> 11.0.0'
s.dependency 'BrazeUI', '~> 11.0.0'
s.dependency 'BrazeKit', '~> 11.1.1'
s.dependency 'BrazeLocation', '~> 11.1.1'
s.dependency 'BrazeUI', '~> 11.1.1'

# Swift/Objective-C compatibility
s.pod_target_xcconfig = {
Expand Down
Loading

0 comments on commit ca6c1f9

Please sign in to comment.