@@ -2,15 +2,18 @@ import 'dart:async';
22import 'package:flutter/services.dart' ;
33import 'package:onesignal_flutter/src/subscription.dart' ;
44
5+ typedef void OnPushSubscriptionChangeObserver (
6+ OSPushSubscriptionChangedState stateChanges);
7+
58class OneSignalPushSubscription {
69 MethodChannel _channel = const MethodChannel ('OneSignal#pushsubscription' );
710
811 String ? _id;
912 String ? _token;
1013 bool ? _optedIn;
1114
12- List <OneSignalPushSubscriptionObserver > _observers =
13- < OneSignalPushSubscriptionObserver > [];
15+ List <OnPushSubscriptionChangeObserver > _observers =
16+ < OnPushSubscriptionChangeObserver > [];
1417 // constructor method
1518 OneSignalPushSubscription () {
1619 this ._channel.setMethodCallHandler (_handleMethod);
@@ -49,12 +52,12 @@ class OneSignalPushSubscription {
4952 /// The OSPushSubscriptionObserver.onOSPushSubscriptionChanged method will be fired on the passed-in
5053 // object when the push subscription changes. This method returns the current OSPushSubscriptionState
5154 // at the time of adding this observer.
52- void addObserver (OneSignalPushSubscriptionObserver observer) {
55+ void addObserver (OnPushSubscriptionChangeObserver observer) {
5356 _observers.add (observer);
5457 }
5558
5659 // Remove a push subscription observer that has been previously added.
57- void removeObserver (OneSignalPushSubscriptionObserver observer) {
60+ void removeObserver (OnPushSubscriptionChangeObserver observer) {
5861 _observers.remove (observer);
5962 }
6063
@@ -81,12 +84,7 @@ class OneSignalPushSubscription {
8184 this ._optedIn = stateChanges.current.optedIn;
8285
8386 for (var observer in _observers) {
84- observer. onOSPushSubscriptionChange (stateChanges);
87+ observer (stateChanges);
8588 }
8689 }
8790}
88-
89- class OneSignalPushSubscriptionObserver {
90- void onOSPushSubscriptionChange (
91- OSPushSubscriptionChangedState stateChanges) {}
92- }
0 commit comments