File tree Expand file tree Collapse file tree 5 files changed +21
-3
lines changed
android/src/main/java/com/onesignal/flutter Expand file tree Collapse file tree 5 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,8 @@ else if (call.method.contentEquals("OneSignal#lifecycleInit"))
68
68
this .lifecycleInit ();
69
69
else if (call .method .contentEquals ("OneSignal#proceedWithWillDisplay" ))
70
70
this .proceedWithWillDisplay (call , result );
71
+ else if (call .method .contentEquals ("OneSignal#addNativeClickListener" ))
72
+ this .registerClickListener ();
71
73
else
72
74
replyNotImplemented (result );
73
75
}
@@ -184,7 +186,10 @@ public void onNotificationPermissionChange(boolean permission) {
184
186
185
187
private void lifecycleInit () {
186
188
OneSignal .getNotifications ().addForegroundLifecycleListener (this );
187
- OneSignal .getNotifications ().addClickListener (this );
188
189
OneSignal .getNotifications ().addPermissionObserver (this );
189
190
}
191
+
192
+ private void registerClickListener () {
193
+ OneSignal .getNotifications ().addClickListener (this );
194
+ }
190
195
}
Original file line number Diff line number Diff line change @@ -73,6 +73,8 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
73
73
[self lifecycleInit: call withResult: result];
74
74
else if ([@" OneSignal#proceedWithWillDisplay" isEqualToString: call.method])
75
75
[self proceedWithWillDisplay: call withResult: result];
76
+ else if ([@" OneSignal#addNativeClickListener" isEqualToString: call.method])
77
+ [self registerClickListener: call withResult: result];
76
78
else
77
79
result (FlutterMethodNotImplemented);
78
80
}
@@ -103,11 +105,15 @@ - (void)registerForProvisionalAuthorization:(FlutterMethodCall *)call withResult
103
105
104
106
- (void )lifecycleInit : (FlutterMethodCall *)call withResult : (FlutterResult)result {
105
107
[OneSignal.Notifications addForegroundLifecycleListener: self ];
106
- [OneSignal.Notifications addClickListener: self ];
107
108
[OneSignal.Notifications addPermissionObserver: self ];
108
109
result (nil );
109
110
}
110
111
112
+ - (void )registerClickListener : (FlutterMethodCall *)call withResult : (FlutterResult)result {
113
+ [OneSignal.Notifications addClickListener: self ];
114
+ result (nil );
115
+ }
116
+
111
117
- (void )onNotificationPermissionDidChange : (BOOL )permission {
112
118
[self .channel invokeMethod: @" OneSignal#onNotificationPermissionDidChange" arguments: @{@" permission" : @(permission)}];
113
119
}
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ + (instancetype)sharedInstance {
55
55
#pragma mark FlutterPlugin
56
56
+ (void )registerWithRegistrar : (NSObject <FlutterPluginRegistrar>*)registrar {
57
57
58
+ [OneSignal initialize: nil withLaunchOptions: nil ];
58
59
OneSignalWrapper.sdkType = @" flutter" ;
59
60
OneSignalWrapper.sdkVersion = @" 050001" ;
60
61
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ Pod::Spec.new do |s|
13
13
s . source_files = 'Classes/**/*'
14
14
s . public_header_files = 'Classes/**/*.h'
15
15
s . dependency 'Flutter'
16
- s . dependency 'OneSignalXCFramework' , '5.0.1 '
16
+ s . dependency 'OneSignalXCFramework' , '5.0.2 '
17
17
s . ios . deployment_target = '11.0'
18
18
s . static_framework = true
19
19
end
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ class OneSignalNotifications {
31
31
32
32
bool _permission = false ;
33
33
34
+ bool _clickHandlerRegistered = false ;
35
+
34
36
/// Whether this app has push notification permission.
35
37
bool get permission {
36
38
return _permission;
@@ -177,6 +179,10 @@ class OneSignalNotifications {
177
179
/// The notification click listener is called whenever the user opens a
178
180
/// OneSignal push notification, or taps an action button on a notification.
179
181
void addClickListener (OnNotificationClickListener listener) {
182
+ if (! _clickHandlerRegistered) {
183
+ _clickHandlerRegistered = true ;
184
+ _channel.invokeMethod ("OneSignal#addNativeClickListener" );
185
+ }
180
186
_clickListeners.add (listener);
181
187
}
182
188
You can’t perform that action at this time.
0 commit comments