Skip to content

Commit 181b8fa

Browse files
fix: call SDK start method instead of plugin start method for iOS
1 parent efe7caf commit 181b8fa

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
**Expo**
88
- Added support for Expo SDK 53.
99

10+
**Core**
11+
- Fixed an issue where opting the SDK after been opted-out would unexpectedly reset default configurations, such as Do Not Disturb setting.
12+
1013

1114
10.0.1
1215
----

ios/RNBatch.mm

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,19 @@ - (NSDictionary*)getConstants {
117117
RCT_EXPORT_METHOD(optIn:(RCTPromiseResolveBlock)resolve
118118
reject:(RCTPromiseRejectBlock)reject)
119119
{
120-
[BatchSDK optIn];
121-
dispatch_async(dispatch_get_main_queue(), ^{
122-
[RNBatch start];
123-
});
120+
if (BatchSDK.isOptedOut) {
121+
// Opt-in SDK
122+
[BatchSDK optIn];
123+
124+
// Get API key and restart sdk
125+
NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
126+
NSString *batchAPIKey = [info objectForKey:@"BatchAPIKey"];
127+
dispatch_async(dispatch_get_main_queue(), ^{
128+
[BatchSDK startWithAPIKey:batchAPIKey];
129+
});
130+
} else {
131+
NSLog(@"RNBatch: Batch SDK is already opted-in");
132+
}
124133
resolve([NSNull null]);
125134
}
126135

0 commit comments

Comments
 (0)