1616import io .flutter .plugin .common .MethodChannel .MethodCallHandler ;
1717import io .flutter .plugin .common .MethodChannel .Result ;
1818
19- public class OneSignalUser extends FlutterMessengerResponder implements MethodCallHandler , IUserStateObserver {
19+ public class OneSignalUser extends FlutterMessengerResponder
20+ implements MethodCallHandler , IUserStateObserver {
2021
2122 static void registerWith (BinaryMessenger messenger ) {
2223 OneSignalUser controller = new OneSignalUser ();
@@ -76,7 +77,7 @@ private void getOnesignalId(MethodCall call, Result result) {
7677 onesignalId = null ;
7778 }
7879 replySuccess (result , onesignalId );
79- }
80+ }
8081
8182 private void getExternalId (MethodCall call , Result result ) {
8283 String externalId = OneSignal .getUser ().getExternalId ();
@@ -85,68 +86,76 @@ private void getExternalId(MethodCall call, Result result) {
8586 }
8687 replySuccess (result , externalId );
8788 }
88-
89+
8990 private void addAliases (MethodCall call , Result result ) {
9091 // 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
9293 try {
9394 OneSignal .getUser ().addAliases ((Map <String , String >) call .arguments );
9495 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 );
97100 }
98101 }
99102
100103 private void removeAliases (MethodCall call , Result result ) {
101104 // 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
103106 try {
104107 OneSignal .getUser ().removeAliases ((List <String >) call .arguments );
105108 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 );
108113 }
109114 }
110115
111116 private void addEmail (MethodCall call , Result result ) {
112117 OneSignal .getUser ().addEmail ((String ) call .arguments );
113118 replySuccess (result , null );
114119 }
115-
120+
116121 private void removeEmail (MethodCall call , Result result ) {
117122 OneSignal .getUser ().removeEmail ((String ) call .arguments );
118123 replySuccess (result , null );
119124 }
120-
125+
121126 private void addSms (MethodCall call , Result result ) {
122127 OneSignal .getUser ().addSms ((String ) call .arguments );
123128 replySuccess (result , null );
124129 }
125-
130+
126131 private void removeSms (MethodCall call , Result result ) {
127132 OneSignal .getUser ().removeSms ((String ) call .arguments );
128133 replySuccess (result , null );
129134 }
130135
131136 private void addTags (MethodCall call , Result result ) {
132137 // 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
134139 try {
135140 OneSignal .getUser ().addTags ((Map <String , String >) call .arguments );
136141 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 );
139146 }
140147 }
141148
142149 private void removeTags (MethodCall call , Result result ) {
143150 // 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
145152 try {
146153 OneSignal .getUser ().removeTags ((List <String >) call .arguments );
147154 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 );
150159 }
151160 }
152161
@@ -157,10 +166,14 @@ private void getTags(MethodCall call, Result result) {
157166 @ Override
158167 public void onUserStateChange (UserChangedState userChangedState ) {
159168 try {
160- invokeMethodOnUiThread ("OneSignal#onUserStateChange" , OneSignalSerializer .convertOnUserStateChange (userChangedState ));
169+ invokeMethodOnUiThread ("OneSignal#onUserStateChange" ,
170+ OneSignalSerializer .convertOnUserStateChange (userChangedState ));
161171 } catch (JSONException e ) {
162172 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 );
164177 }
165178 }
166179}
0 commit comments