@@ -30,53 +30,49 @@ class OneSignal {
30
30
static OneSignalSession Session = new OneSignalSession ();
31
31
static OneSignalLocation Location = new OneSignalLocation ();
32
32
static OneSignalInAppMessages InAppMessages = new OneSignalInAppMessages ();
33
-
34
33
35
34
// private channels used to bridge to ObjC/Java
36
35
MethodChannel _channel = const MethodChannel ('OneSignal' );
37
-
38
- /// The initializer for OneSignal.
36
+
37
+ /// The initializer for OneSignal.
39
38
///
40
- /// The initializer accepts an [appId] which the developer can get
39
+ /// The initializer accepts an [appId] which the developer can get
41
40
/// from the OneSignal consoleas well as a dictonary of [launchOptions]
42
41
void initialize (String appId) {
43
- _channel.invokeMethod (
44
- 'OneSignal#initialize' , { 'appId' : appId} );
42
+ _channel.invokeMethod ('OneSignal#initialize' , { 'appId' : appId});
43
+ InAppMessages . lifecycleInit ( );
45
44
}
46
45
47
- /// Login to OneSignal under the user identified by the [externalId] provided.
48
- ///
49
- /// The act of logging a user into the OneSignal SDK will switch the
46
+ /// Login to OneSignal under the user identified by the [externalId] provided.
47
+ ///
48
+ /// The act of logging a user into the OneSignal SDK will switch the
50
49
/// [user] context to that specific user.
51
50
void login (String externalId) {
52
- _channel.invokeMethod (
53
- 'OneSignal#login' , {'externalId' : externalId});
51
+ _channel.invokeMethod ('OneSignal#login' , {'externalId' : externalId});
54
52
}
55
53
56
- /// Logout the user previously logged in via [login] . The [user] property now
54
+ /// Logout the user previously logged in via [login] . The [user] property now
57
55
///
58
- /// references a new device-scoped user. A device-scoped user has no user identity
59
- /// that can later be retrieved, except through this device as long as the app
56
+ /// references a new device-scoped user. A device-scoped user has no user identity
57
+ /// that can later be retrieved, except through this device as long as the app
60
58
/// remains installed and the app data is not cleared.
61
59
void logout () {
62
- _channel.invokeMethod (
63
- 'OneSignal#logout' );
60
+ _channel.invokeMethod ('OneSignal#logout' );
64
61
}
65
62
66
- /// Indicates whether privacy consent has been granted.
63
+ /// Indicates whether privacy consent has been granted.
67
64
///
68
- /// This field is only relevant when the application has
65
+ /// This field is only relevant when the application has
69
66
/// opted into data privacy protections. See [requiresPrivacyConsent] .
70
67
Future <bool > getPrivacyConsent () async {
71
- var val =
72
- await _channel.invokeMethod ("OneSignal#getPrivacyConsent" );
68
+ var val = await _channel.invokeMethod ("OneSignal#getPrivacyConsent" );
73
69
74
70
return val as bool ;
75
71
}
76
72
77
73
/// Sets the whether or not privacy consent has been [granted]
78
74
///
79
- /// This field is only relevant when the application has
75
+ /// This field is only relevant when the application has
80
76
/// opted into data privacy protections. See [requiresPrivacyConsent] .
81
77
Future <void > setPrivacyConsent (bool granted) async {
82
78
await _channel
@@ -87,8 +83,7 @@ class OneSignal {
87
83
/// user's consent before it can initialize (if you set the app to
88
84
/// require the user's consent)
89
85
Future <bool > requiresPrivacyConsent () async {
90
- var val =
91
- await _channel.invokeMethod ("OneSignal#requiresPrivacyConsent" );
86
+ var val = await _channel.invokeMethod ("OneSignal#requiresPrivacyConsent" );
92
87
93
88
return val as bool ;
94
89
}
@@ -102,8 +97,8 @@ class OneSignal {
102
97
}
103
98
104
99
/// This method can be used to set if launch URLs should be opened in safari or
105
- /// within the application. Set to true to launch all notifications with a URL
106
- /// in the app instead of the default web browser. Make sure to call setLaunchURLsInApp
100
+ /// within the application. Set to true to launch all notifications with a URL
101
+ /// in the app instead of the default web browser. Make sure to call setLaunchURLsInApp
107
102
/// before the initialize call.
108
103
void setLaunchURLsInApp (bool launchUrlsInApp) {
109
104
_channel.invokeMethod (
@@ -114,17 +109,17 @@ class OneSignal {
114
109
/// Associates a temporary push token with an Activity ID on the OneSignal server.
115
110
Future <void > enterLiveActivity (String activityId, String token) async {
116
111
if (Platform .isIOS) {
117
- await _channel.invokeMethod ("OneSignal#enterLiveActivity" , {'activityId' : activityId, 'token' : token});
118
- }
112
+ await _channel.invokeMethod ("OneSignal#enterLiveActivity" ,
113
+ {'activityId' : activityId, 'token' : token});
114
+ }
119
115
}
120
116
121
117
/// Only applies to iOS
122
118
/// Deletes activityId associated temporary push token on the OneSignal server.
123
119
Future <void > exitLiveActivity (String activityId) async {
124
120
if (Platform .isIOS) {
125
- await _channel.invokeMethod ("OneSignal#exitLiveActivity" ,
126
- {'activityId' : activityId});
121
+ await _channel.invokeMethod (
122
+ "OneSignal#exitLiveActivity" , {'activityId' : activityId});
127
123
}
128
124
}
129
-
130
125
}
0 commit comments