@@ -16,6 +16,7 @@ class _MyAppState extends State<MyApp> {
16
16
String ? _emailAddress;
17
17
String ? _smsNumber;
18
18
String ? _externalUserId;
19
+ String ? _language;
19
20
bool _enableConsentButton = false ;
20
21
21
22
// CHANGE THIS parameter to true if you want to test GDPR privacy consent
@@ -184,6 +185,18 @@ class _MyAppState extends State<MyApp> {
184
185
});
185
186
}
186
187
188
+ void _handleSetLanguage () {
189
+ if (_language == null ) return ;
190
+
191
+ print ("Setting language" );
192
+
193
+ OneSignal .shared.setLanguage (_language! ).then ((response) {
194
+ print ("Successfully set language with response: $response " );
195
+ }).catchError ((error) {
196
+ print ("Failed to set language with error: $error " );
197
+ });
198
+ }
199
+
187
200
void _handleLogoutEmail () {
188
201
print ("Logging out of email" );
189
202
@@ -510,6 +523,30 @@ class _MyAppState extends State<MyApp> {
510
523
new OneSignalButton (
511
524
"Remove External User ID" , _handleRemoveExternalUserId, ! _enableConsentButton)
512
525
]),
526
+ new TableRow (children: [
527
+ new TextField (
528
+ textAlign: TextAlign .center,
529
+ decoration: InputDecoration (
530
+ hintText: "Language" ,
531
+ labelStyle: TextStyle (
532
+ color: Color .fromARGB (255 , 212 , 86 , 83 ),
533
+ )),
534
+ onChanged: (text) {
535
+ this .setState (() {
536
+ _language = text == "" ? null : text;
537
+ });
538
+ },
539
+ )
540
+ ]),
541
+ new TableRow (children: [
542
+ Container (
543
+ height: 8.0 ,
544
+ )
545
+ ]),
546
+ new TableRow (children: [
547
+ new OneSignalButton (
548
+ "Set Language" , _handleSetLanguage, ! _enableConsentButton)
549
+ ]),
513
550
new TableRow (children: [
514
551
new Container (
515
552
child: new Text (_debugLabelString),
0 commit comments