Skip to content

Commit bd03ab7

Browse files
committed
Add iOS version checks consistently
Remove autorelease pool
1 parent 452f6bd commit bd03ab7

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

ios/Classes/OSFlutterLiveActivities.m

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,26 +82,34 @@ - (void)exitLiveActivity:(FlutterMethodCall *)call withResult:(FlutterResult)res
8282
- (void)setPushToStartToken:(FlutterMethodCall *)call withResult:(FlutterResult)result {
8383
NSString *activityType = call.arguments[@"activityType"];
8484
NSString *token = call.arguments[@"token"];
85+
NSError* err=nil;
8586

86-
@autoreleasepool {
87-
NSError* err=nil;
87+
if (@available(iOS 17.2, *)) {
8888
[OneSignalLiveActivitiesManagerImpl setPushToStartToken:activityType withToken:token error:&err];
8989
if (err) {
9090
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"activityType must be the name of your ActivityAttributes struct"]];
9191
}
92+
} else {
93+
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot setPushToStartToken on iOS < 17.2"]];
9294
}
95+
96+
result(nil);
9397
}
9498

9599
- (void)removePushToStartToken:(FlutterMethodCall *)call withResult:(FlutterResult)result {
96100
NSString *activityType = call.arguments[@"activityType"];
101+
NSError* err=nil;
97102

98-
@autoreleasepool {
99-
NSError* err=nil;
103+
if (@available(iOS 17.2, *)) {
100104
[OneSignalLiveActivitiesManagerImpl removePushToStartToken:activityType error:&err];
101105
if (err) {
102106
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"activityType must be the name of your ActivityAttributes struct"]];
103107
}
108+
} else {
109+
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot removePushToStartToken on iOS < 17.2"]];
104110
}
111+
112+
result(nil);
105113
}
106114

107115
- (void)setupDefault:(FlutterMethodCall *)call withResult:(FlutterResult)result {
@@ -120,6 +128,8 @@ - (void)setupDefault:(FlutterMethodCall *)call withResult:(FlutterResult)result
120128
} else {
121129
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot setupDefault on iOS < 16.1"]];
122130
}
131+
132+
result(nil);
123133
}
124134

125135
- (void)startDefault:(FlutterMethodCall *)call withResult:(FlutterResult)result {
@@ -132,6 +142,8 @@ - (void)startDefault:(FlutterMethodCall *)call withResult:(FlutterResult)result
132142
} else {
133143
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot startDefault on iOS < 16.1"]];
134144
}
145+
146+
result(nil);
135147
}
136148

137149
@end

0 commit comments

Comments
 (0)