Skip to content

Commit d66a192

Browse files
committed
Implement Cold Start Notification Open
• Adds ability for the SDK to notify Flutter clients if the user opened the app by tapping a notification/tapping a button on a notification.
1 parent 3823367 commit d66a192

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ios/Classes/OneSignalPlugin.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ + (instancetype)sharedInstance
7272
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
7373

7474
[OneSignal initWithLaunchOptions:nil appId:nil handleNotificationAction:^(OSNotificationOpenedResult *result) {
75-
75+
@synchronized (OneSignalPlugin.sharedInstance.coldStartOpenResult) {
76+
OneSignalPlugin.sharedInstance.coldStartOpenResult = result;
77+
}
7678
}];
7779

7880
OneSignalPlugin.sharedInstance.channel = [FlutterMethodChannel
@@ -139,6 +141,12 @@ - (void)initOneSignal:(FlutterMethodCall *)call withResult:(FlutterResult)result
139141
[self addObservers];
140142
}
141143

144+
@synchronized(self.coldStartOpenResult) {
145+
if (self.coldStartOpenResult) {
146+
[self handleNotificationOpened:self.coldStartOpenResult];
147+
}
148+
}
149+
142150
result(@[]);
143151
}
144152

0 commit comments

Comments
 (0)