openimsdk / open-im-sdk-flutter

IM SDK Flutter
https://openim.io
MIT License
362 stars 227 forks source link

[BUG] OpenIM Integration Issue in Existing Flutter App #136

Closed akashshrestha123 closed 1 month ago

akashshrestha123 commented 3 months ago

I'm facing an issue where the OpenIM SDK works perfectly in a standalone Flutter app but fails to function correctly when integrated into my existing Flutter application. I've followed the integration instructions carefully, but I'm still unable to get OpenIM features working within my existing app.

Here's a summary of what I've tried:

Could you please help me with the following questions:

Are there any known compatibility issues between OpenIM and the specific versions of Flutter or other dependencies I'm using in my existing app? Are there any specific configuration settings or steps that are critical for successful integration within an existing Flutter app? Could there be any conflicts between the OpenIM SDK and other libraries or components in my existing app? Are there any debugging techniques or tools you recommend to identify the root cause of this integration problem?

Additional Tips:

std-s commented 3 months ago

@akashshrestha123 Hi, please provide the error information.

akashshrestha123 commented 3 months ago

Hey @std-s thank you so much for your response. I don't any kinds of error logs. since i have few question . Urgent: OpenIM Listener Callbacks Not Triggering in Embedded Flutter App

We are encountering a critical issue with the OpenIM Flutter SDK not triggering listener callbacks when integrated into our existing Flutter application.

Key Points:

Steps Taken:

Request to OpenIM Team:

  1. Are there any known compatibility issues: Specifically between the OpenIM Flutter SDK v3.5.1 and our Flutter version (3.0.2) or other dependencies we are using?

  2. Specific Configuration for Embedded Apps: Are there any special configuration settings or steps required when embedding the OpenIM SDK within an existing Flutter app (as opposed to a standalone app)?

  3. Possible Conflicts: Could there be potential conflicts between the OpenIM SDK and other libraries or components commonly used in Flutter apps, such as Firebase or go_router?

  4. Debugging Recommendations: Could you provide more guidance on how to further debug this issue? Are there specific logs or areas in the native code that we should focus on to identify the problem?

  5. Alternative Solutions: Are there any alternative approaches or workarounds you recommend for handling listener callbacks when embedding the OpenIM SDK in a complex Flutter app?

Additional Notes:

We would greatly appreciate any assistance you can provide in resolving this issue. Please let us know if you need any further information or code snippets to help you diagnose the problem.

std-s commented 3 months ago

@akashshrestha123 hi, Have you set up a listener? Something like this.

akashshrestha123 commented 3 months ago

@std-s Yeah exactly i did. when i create simple app doing this all it is working correctly calling every listener method in flutter side but when integrate in my existing e-learning app only "onConnecting" is called in flutter side after that nothing is called in flutter side but when i see logger that is came from native side every listener method is calling properly.

cipchk commented 3 months ago

I have the exact same situation, but my iOS works fine. However, on Android, only onConnecting and onConnectSuccess are triggered, and none of the other event listeners are triggered at all.

We can obtain the following logs, but we are unable to trigger Flutter's listening events.

I/F-OpenIMSDK(flutter call native)(19498): { class:conversationManager,  method:setConversationEx }
I/F-OpenIMSDK(flutter call native)(19498): { class:conversationManager,  method:getConversationListSplit }
I/F-OpenIMSDK(flutter call native)(19498): { class:conversationManager,  method:setConversationEx }

Doctor -v:

[✓] Flutter (Channel stable, 3.22.1, on macOS 14.5 23F79 darwin-x64, locale zh-Hans-CN)
    • Flutter version 3.22.1 on channel stable at /Users/cipchk/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a14f74ff3a (4 weeks ago), 2024-05-22 11:08:21 -0500
    • Engine revision 55eae6864b
    • Dart version 3.4.1
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/cipchk/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/cipchk/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/cipchk/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.90.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.90.0

[✓] Connected device (3 available)
    • SM G996U (mobile) • RFCNC0J4X2J • android-arm64  • Android 14 (API 34)
    • macOS (desktop)   • macos       • darwin-x64     • macOS 14.5 23F79 darwin-x64
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 126.0.6478.63
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```[✓] Flutter (Channel stable, 3.22.1, on macOS 14.5 23F79 darwin-x64, locale zh-Hans-CN)
    • Flutter version 3.22.1 on channel stable at /Users/cipchk/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a14f74ff3a (4 weeks ago), 2024-05-22 11:08:21 -0500
    • Engine revision 55eae6864b
    • Dart version 3.4.1
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/cipchk/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/cipchk/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/cipchk/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.90.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.90.0

[✓] Connected device (3 available)
    • SM G996U (mobile) • RFCNC0J4X2J • android-arm64  • Android 14 (API 34)
    • macOS (desktop)   • macos       • darwin-x64     • macOS 14.5 23F79 darwin-x64
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 126.0.6478.63
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!
std-s commented 3 months ago

@akashshrestha123 @cipchk
Hi, the main steps are to initialize the SDK, set the listener, and log in. This file shows the functions of initializing the SDK and setting the listener. You can run our open source Demo first.

cipchk commented 3 months ago

@std-s My test phone is a Samsung. How about you? @akashshrestha123

Other than Samsung (Galaxy S21+ 5G), I have tested brands like Xiaomi and Huawei, and everything works fine.

akashshrestha123 commented 3 months ago

@cipchk mine also samsung galaxy a50. and are you sure it is working in xiaomi and huawei. are you creating simple or integrating in existing project?

akashshrestha123 commented 3 months ago

@std-s is it something with flutter version also? since i am at flutter version 3.0.2. When i create simple app or creating new project every single listener and every thing is working correctly. Since i have a little heavy application that is e-learning and has a lot of package used. Did i miss something? Does it also depends on how our flutter project is structured?

cipchk commented 3 months ago

@akashshrestha123 Yes, my Samsung device is similar to yours. Since we need to launch on Google Play, the minimum build version required is 30 or above. However, the official version provided is 26, so I feel the issue might be with the build version. I don't have the means to test this on my end; could you possibly conduct some tests on the build level? I believe it is indeed a build issue.

Here is the https://github.com/openimsdk/open-im-sdk-flutter/issues/136#issuecomment-2182211239 with my Flutter environment, which also includes the Android part:

cipchk commented 3 months ago

@akashshrestha123 Any progress?

akashshrestha123 commented 2 months ago

@cipchk Thank you for you reply. I haven't tried yet. I will try and let you know.

cipchk commented 2 months ago

@akashshrestha123 Any progress?

akashshrestha123 commented 2 months ago

@cipchk i tried but still same issue. Any progress from your side?

cipchk commented 2 months ago

I can work, but I can't explain to you why because I didn't make any fixes and it suddenly started working again without any warning.

The only thing I can think of that has changed is the User Token, you could try redeploying OPENIM Serve and see if that solves your problem.

It's a very strange phenomenon that I can't explain.

akashshrestha123 commented 2 months ago

Yeah I do understand. I am also facing strange issue. when i create new project and try to run it is working properly but i am still facing same issue on integrating in existing system. At the moment i am feeling helpless and asking my team should we find other ways. Please give me any other solution if you have.

std-s commented 1 month ago

It hasn't made any sound for a long time, turn it off first.