Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Cannot set language for android platform #48

Closed
lesonlhld opened this issue Aug 15, 2023 · 2 comments
Closed

[Bug] Cannot set language for android platform #48

lesonlhld opened this issue Aug 15, 2023 · 2 comments
Labels
awaiting user input Awaiting input from the user for a query

Comments

@lesonlhld
Copy link

Hi team,

I'm having trouble setting or changing the language. I checked everything in your guide, and it's fine. And iOS still works fine.

But for Android, nothing happens without any error or exception.
I run your example code, it's the same

If I put the setLanguage function after the init function, it throws an exception the first time I run the app like this screenshot and the floating button is not visible

await ZohoSalesIQ.setLanguage('vi');
// initialization successful
await ZohoSalesIQ.showLauncher(true);

image

And if I wrap the setLanguage function with unawaited or put it after showLauncher, it throws the same exception and shows the float button in English language

unawaited(ZohoSalesIQ.setLanguage('vi'));
// initialization successful
await ZohoSalesIQ.showLauncher(true);

Or if I remove the setLanguage function in the init function and put it in the Button widget, setLanguage also does not work with asynchronous or not

TextButton(
  onPressed: () {
    try {
      ZohoSalesIQ.setLanguage('vi');
      ZohoSalesIQ.show();
    } catch (e) {
      print(e.toString());
    }
  },
  child: const Text('Click to open Zoho SalesIQ'),
),

Here is the example code

import 'dart:async';
import 'dart:io' as io;

import 'package:flutter/material.dart';
import 'package:salesiq_mobilisten/salesiq_mobilisten.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    initPlatformState();
    initMobilisten();
  }

  Future<void> initMobilisten() async {
    if (io.Platform.isIOS || io.Platform.isAndroid) {
      String appKey;
      String accessKey;
      if (io.Platform.isIOS) {
        appKey = 'INSERT_IOS_APP_KEY';
        accessKey = 'INSERT_IOS_ACCESS_KEY';
      } else {
        appKey = 'INSERT_ANDROID_APP_KEY';
        accessKey = 'INSERT_ANDROID_ACCESS_KEY';
      }
      await ZohoSalesIQ.init(appKey, accessKey).then((_) async {
        try {
          await ZohoSalesIQ.setLanguage('vi');
          // initialization successful
          await ZohoSalesIQ.showLauncher(true);
        } catch (e) {
          print(e.toString());
        }
      }).catchError((error) {
        // initialization failed
        print(error);
      });
      await ZohoSalesIQ.setThemeColorForiOS('#6d85fc');
    }
  }

  Future<void> initPlatformState() async {
    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Example Application'),
        ),
        body: Center(
          child: TextButton(
            onPressed: () {
              try {
                ZohoSalesIQ.setLanguage('vi');
                ZohoSalesIQ.show();
              } catch (e) {
                print(e.toString());
              }
            },
            child: const Text('Click to open Zoho SalesIQ'),
          ),
        ),
      ),
    );
  }
}

I think it can be the same issue #6
Please help me check this problem.

Thank you!
Son.

@bhahirathan-mb-11956 bhahirathan-mb-11956 added the awaiting user input Awaiting input from the user for a query label Aug 30, 2023
@bhahirathan-mb-11956
Copy link
Collaborator

Hi @lesonlhld ,
We have evaluated the same instances you've provided in the sample above. However, it is working fine from our side. To resolve this issue, please write us at (support@zohosalesiq.com). We will be happy to help you.

Thanks,
Bhahirathan M
Zoho SalesIQ

@lesonlhld
Copy link
Author

Thanks for answering!

I have solved this problem. That's because my project has problem in Android source code. It is too difficult to detect the root cause 😅
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting user input Awaiting input from the user for a query
Projects
None yet
Development

No branches or pull requests

2 participants