Skip to content

Commit 5e8928c

Browse files
committed
Add iOS version checks consistently
Remove autoreleasepool Minor example app updates
1 parent 8299d41 commit 5e8928c

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

examples/RNOneSignalTS/ios/Podfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ DEPENDENCIES:
323323
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
324324
- FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`)
325325
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
326-
- OneSignalXCFramework (= 5.2.0)
326+
- OneSignalXCFramework (< 6.0.0, >= 5.0.2)
327327
- RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
328328
- RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`)
329329
- RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`)
@@ -450,6 +450,6 @@ SPEC CHECKSUMS:
450450
ReactCommon: b4a65d2d6e9eeffd4b32dde1245962b3f43907d0
451451
Yoga: d1fc3575b8b68891ff5ef3c276daa855e841eb32
452452

453-
PODFILE CHECKSUM: 74dbbba09d2d611b469faf8787a048dd71c49137
453+
PODFILE CHECKSUM: f48dbc25fab0526ba40a2fa6aadce3376f5c6602
454454

455455
COCOAPODS: 1.15.2

examples/RNOneSignalTS/src/OSButtons.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class OSButtons extends React.Component<Props> {
227227
const setPushToStartLiveActivity = renderButtonView(
228228
'Set Push-To-Start Live Activity',
229229
async () => {
230-
loggingFunction('Exiting live activity');
230+
loggingFunction('Set pushToStart token');
231231
await OneSignal.LiveActivities.setPushToStartToken(
232232
this.props.inputFieldValue,
233233
'FAKE_TOKEN',
@@ -238,7 +238,7 @@ class OSButtons extends React.Component<Props> {
238238
const removePushToStartLiveActivity = renderButtonView(
239239
'Remove Push-To-Start Live Activity',
240240
async () => {
241-
loggingFunction('Exiting live activity');
241+
loggingFunction('Remove pushToStart token');
242242
await OneSignal.LiveActivities.removePushToStartToken(
243243
this.props.inputFieldValue,
244244
);

ios/RCTOneSignal/RCTOneSignalEventEmitter.m

+20-6
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,28 @@ + (void)sendEventWithName:(NSString *)name withBody:(NSDictionary *)body {
133133

134134
RCT_EXPORT_METHOD(setPushToStartToken:(NSString *)activityType
135135
withToken:(NSString *)token) {
136-
@autoreleasepool {
137-
NSError* err=nil;
136+
NSError* err=nil;
137+
138+
if (@available(iOS 17.2, *)) {
138139
[OneSignalLiveActivitiesManagerImpl setPushToStartToken:activityType withToken:token error:&err];
139140
if (err) {
140141
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"activityType must be the name of your ActivityAttributes struct"]];
141142
}
143+
} else {
144+
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot setPushToStartToken on iOS < 17.2"]];
142145
}
143146
}
144147

145148
RCT_EXPORT_METHOD(removePushToStartToken:(NSString *)activityType) {
146-
@autoreleasepool {
147-
NSError* err=nil;
149+
NSError* err=nil;
150+
151+
if (@available(iOS 17.2, *)) {
148152
[OneSignalLiveActivitiesManagerImpl removePushToStartToken:activityType error:&err];
149153
if (err) {
150154
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"activityType must be the name of your ActivityAttributes struct"]];
151155
}
156+
} else {
157+
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot removePushToStartToken on iOS < 17.2"]];
152158
}
153159
}
154160

@@ -161,14 +167,22 @@ + (void)sendEventWithName:(NSString *)name withBody:(NSDictionary *)body {
161167
[laOptions setEnablePushToUpdate:[options[@"enablePushToUpdate"] boolValue]];
162168
}
163169

164-
[OneSignalLiveActivitiesManagerImpl setupDefaultWithOptions:laOptions];
170+
if (@available(iOS 16.1, *)) {
171+
[OneSignalLiveActivitiesManagerImpl setupDefaultWithOptions:laOptions];
172+
} else {
173+
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot setupDefault on iOS < 16.1"]];
174+
}
165175
}
166176

167177
RCT_EXPORT_METHOD(startDefaultLiveActivity:(NSString *)activityId
168178
withAttributes:(NSDictionary * _Nonnull)attributes
169179
withContent:(NSDictionary * _Nonnull)content) {
170180

171-
[OneSignalLiveActivitiesManagerImpl startDefault:activityId attributes:attributes content:content];
181+
if (@available(iOS 16.1, *)) {
182+
[OneSignalLiveActivitiesManagerImpl startDefault:activityId attributes:attributes content:content];
183+
} else {
184+
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot startDefault on iOS < 16.1"]];
185+
}
172186
}
173187

174188
RCT_EXPORT_METHOD(setPrivacyConsentGiven:(BOOL)granted) {

0 commit comments

Comments
 (0)