@@ -36,12 +36,94 @@ class OneSignal {
36
36
_channel.invokeMethod (
37
37
'OneSignal#initialize' , {'appId' : appId});
38
38
}
39
- // constructor method
40
- // OneSignal() {
41
- // this._channel.setMethodCallHandler(_handleMethod);
42
- // }
43
- // // Private function that gets called by ObjC/Java
44
- // Future<Null> _handleMethod(MethodCall call) async {
45
- // return null;
46
- // }
39
+
40
+ /// Login to OneSignal under the user identified by the [externalId] provided.
41
+ ///
42
+ /// The act of logging a user into the OneSignal SDK will switch the
43
+ /// [user] context to that specific user.
44
+ void login (String externalId) {
45
+ _channel.invokeMethod (
46
+ 'OneSignal#login' , {'externalId' : externalId});
47
+ }
48
+
49
+ /// Logout the user previously logged in via [login] . The [user] property now
50
+ ///
51
+ /// references a new device-scoped user. A device-scoped user has no user identity
52
+ /// that can later be retrieved, except through this device as long as the app
53
+ /// remains installed and the app data is not cleared.
54
+ void logout () {
55
+ _channel.invokeMethod (
56
+ 'OneSignal#logout' );
57
+ }
58
+
59
+ /// Indicates whether privacy consent has been granted.
60
+ ///
61
+ /// This field is only relevant when the application has
62
+ /// opted into data privacy protections. See [requiresPrivacyConsent] .
63
+ Future <bool > getPrivacyConsent () async {
64
+ var val =
65
+ await _channel.invokeMethod ("OneSignal#getPrivacyConsent" );
66
+
67
+ return val as bool ;
68
+ }
69
+
70
+ /// Sets the whether or not privacy consent has been [granted]
71
+ ///
72
+ /// This field is only relevant when the application has
73
+ /// opted into data privacy protections. See [requiresPrivacyConsent] .
74
+ Future <void > setPrivacyConsent (bool granted) async {
75
+ await _channel
76
+ .invokeMethod ("OneSignal#setPrivacyConsent" , {'granted' : granted});
77
+ }
78
+
79
+ /// A boolean value indicating if the OneSignal SDK is waiting for the
80
+ /// user's consent before it can initialize (if you set the app to
81
+ /// require the user's consent)
82
+ Future <bool > requiresPrivacyConsent () async {
83
+ var val =
84
+ await _channel.invokeMethod ("OneSignal#requiresPrivacyConsent" );
85
+
86
+ return val as bool ;
87
+ }
88
+
89
+ /// Allows you to completely disable the SDK until your app calls the
90
+ /// OneSignal.setPrivacyConsent(true) function. This is useful if you want
91
+ /// to show a Terms and Conditions or privacy popup for GDPR.
92
+ Future <void > setRequiresPrivacyConsent (bool require) async {
93
+ await _channel.invokeMethod (
94
+ "OneSignal#setRequiresPrivacyConsent" , {'required' : require});
95
+ }
96
+
97
+ /// This method can be used to set if launch URLs should be opened in safari or
98
+ /// within the application. Set to true to launch all notifications with a URL
99
+ /// in the app instead of the default web browser. Make sure to call setLaunchURLsInApp
100
+ /// before the initialize call.
101
+ void setLaunchURLsInApp (bool launchUrlsInApp) {
102
+ _channel.invokeMethod (
103
+ 'OneSignal#setLaunchURLsInApp' , {'launchUrlsInApp' : launchUrlsInApp});
104
+ }
105
+
106
+ /// Only applies to iOS
107
+ /// Associates a temporary push token with an Activity ID on the OneSignal server.
108
+ Future <void > enterLiveActivity (String activityId, String token) async {
109
+ if (Platform .isIOS) {
110
+ await _channel.invokeMethod ("OneSignal#enterLiveActivity" , {'activityId' : activityId, 'token' : token});
111
+ } else {
112
+ _onesignalLog (OSLogLevel .info,
113
+ "enterLiveActivity: this function is not supported on Android" );
114
+ }
115
+ }
116
+
117
+ /// Only applies to iOS
118
+ /// Deletes activityId associated temporary push token on the OneSignal server.
119
+ Future <void > exitLiveActivity (String activityId) async {
120
+ if (Platform .isIOS) {
121
+ await _channel.invokeMethod ("OneSignal#exitLiveActivity" ,
122
+ {'activityId' : activityId});
123
+ } else {
124
+ _onesignalLog (OSLogLevel .info,
125
+ "exitLiveActivity: this function is not supported on Android" );
126
+ }
127
+ }
128
+
47
129
}
0 commit comments