16
16
import io .flutter .plugin .common .MethodChannel .MethodCallHandler ;
17
17
import io .flutter .plugin .common .MethodChannel .Result ;
18
18
19
- public class OneSignalUser extends FlutterMessengerResponder implements MethodCallHandler , IUserStateObserver {
19
+ public class OneSignalUser extends FlutterMessengerResponder
20
+ implements MethodCallHandler , IUserStateObserver {
20
21
21
22
static void registerWith (BinaryMessenger messenger ) {
22
23
OneSignalUser controller = new OneSignalUser ();
@@ -76,7 +77,7 @@ private void getOnesignalId(MethodCall call, Result result) {
76
77
onesignalId = null ;
77
78
}
78
79
replySuccess (result , onesignalId );
79
- }
80
+ }
80
81
81
82
private void getExternalId (MethodCall call , Result result ) {
82
83
String externalId = OneSignal .getUser ().getExternalId ();
@@ -85,68 +86,76 @@ private void getExternalId(MethodCall call, Result result) {
85
86
}
86
87
replySuccess (result , externalId );
87
88
}
88
-
89
+
89
90
private void addAliases (MethodCall call , Result result ) {
90
91
// call.arguments is being casted to a Map<String, Object> so a try-catch with
91
- // a ClassCastException will be thrown
92
+ // a ClassCastException will be thrown
92
93
try {
93
94
OneSignal .getUser ().addAliases ((Map <String , String >) call .arguments );
94
95
replySuccess (result , null );
95
- } catch (ClassCastException e ) {
96
- replyError (result , "OneSignal" , "addAliases failed with error: " + e .getMessage () + "\n " + e .getStackTrace (), null );
96
+ } catch (ClassCastException e ) {
97
+ replyError (result , "OneSignal" ,
98
+ "addAliases failed with error: " + e .getMessage () + "\n " + e .getStackTrace (),
99
+ null );
97
100
}
98
101
}
99
102
100
103
private void removeAliases (MethodCall call , Result result ) {
101
104
// call.arguments is being casted to a List<String> so a try-catch with
102
- // a ClassCastException will be thrown
105
+ // a ClassCastException will be thrown
103
106
try {
104
107
OneSignal .getUser ().removeAliases ((List <String >) call .arguments );
105
108
replySuccess (result , null );
106
- } catch (ClassCastException e ) {
107
- replyError (result , "OneSignal" , "removeAliases failed with error: " + e .getMessage () + "\n " + e .getStackTrace (), null );
109
+ } catch (ClassCastException e ) {
110
+ replyError (result , "OneSignal" ,
111
+ "removeAliases failed with error: " + e .getMessage () + "\n " + e .getStackTrace (),
112
+ null );
108
113
}
109
114
}
110
115
111
116
private void addEmail (MethodCall call , Result result ) {
112
117
OneSignal .getUser ().addEmail ((String ) call .arguments );
113
118
replySuccess (result , null );
114
119
}
115
-
120
+
116
121
private void removeEmail (MethodCall call , Result result ) {
117
122
OneSignal .getUser ().removeEmail ((String ) call .arguments );
118
123
replySuccess (result , null );
119
124
}
120
-
125
+
121
126
private void addSms (MethodCall call , Result result ) {
122
127
OneSignal .getUser ().addSms ((String ) call .arguments );
123
128
replySuccess (result , null );
124
129
}
125
-
130
+
126
131
private void removeSms (MethodCall call , Result result ) {
127
132
OneSignal .getUser ().removeSms ((String ) call .arguments );
128
133
replySuccess (result , null );
129
134
}
130
135
131
136
private void addTags (MethodCall call , Result result ) {
132
137
// call.arguments is being casted to a Map<String, Object> so a try-catch with
133
- // a ClassCastException will be thrown
138
+ // a ClassCastException will be thrown
134
139
try {
135
140
OneSignal .getUser ().addTags ((Map <String , String >) call .arguments );
136
141
replySuccess (result , null );
137
- } catch (ClassCastException e ) {
138
- replyError (result , "OneSignal" , "addTags failed with error: " + e .getMessage () + "\n " + e .getStackTrace (), null );
142
+ } catch (ClassCastException e ) {
143
+ replyError (result , "OneSignal" ,
144
+ "addTags failed with error: " + e .getMessage () + "\n " + e .getStackTrace (),
145
+ null );
139
146
}
140
147
}
141
148
142
149
private void removeTags (MethodCall call , Result result ) {
143
150
// call.arguments is being casted to a List<String> so a try-catch with
144
- // a ClassCastException will be thrown
151
+ // a ClassCastException will be thrown
145
152
try {
146
153
OneSignal .getUser ().removeTags ((List <String >) call .arguments );
147
154
replySuccess (result , null );
148
- } catch (ClassCastException e ) {
149
- replyError (result , "OneSignal" , "deleteTags failed with error: " + e .getMessage () + "\n " + e .getStackTrace (), null );
155
+ } catch (ClassCastException e ) {
156
+ replyError (result , "OneSignal" ,
157
+ "deleteTags failed with error: " + e .getMessage () + "\n " + e .getStackTrace (),
158
+ null );
150
159
}
151
160
}
152
161
@@ -157,10 +166,14 @@ private void getTags(MethodCall call, Result result) {
157
166
@ Override
158
167
public void onUserStateChange (UserChangedState userChangedState ) {
159
168
try {
160
- invokeMethodOnUiThread ("OneSignal#onUserStateChange" , OneSignalSerializer .convertOnUserStateChange (userChangedState ));
169
+ invokeMethodOnUiThread ("OneSignal#onUserStateChange" ,
170
+ OneSignalSerializer .convertOnUserStateChange (userChangedState ));
161
171
} catch (JSONException e ) {
162
172
e .getStackTrace ();
163
- Logging .error ("Encountered an error attempting to convert UserChangedState object to hash map:" + e .toString (), null );
173
+ Logging .error (
174
+ "Encountered an error attempting to convert UserChangedState object to hash map:"
175
+ + e .toString (),
176
+ null );
164
177
}
165
178
}
166
179
}
0 commit comments