intercom_flutter
intercom_flutter copied to clipboard
Api call failed | Forbidden request
Code I am using
try {
final currentUser = FirebaseAuth.instance.currentUser;
await Intercom.instance.logout();
await Intercom.instance.loginIdentifiedUser(
userId: currentUser?.uid,
// email: currentUser?.email,
statusCallback:
IntercomStatusCallback(onFailure: (error) {
print('ERROR ${error.errorMessage}');
}));
await Intercom.instance.displayMessenger();
} catch (e) {
print("CATCHED ERRO $e");
}
Here are the logs I am getting
D/SessionLifecycleService( 7143): Activity backgrounding at 2864519
D/SessionLifecycleClient( 7143): Sending lifecycle 1 to service
D/EGL_emulation( 7143): app_time_stats: avg=77.97ms min=9.20ms max=2715.02ms count=45
D/SessionLifecycleService( 7143): Activity foregrounding at 2864661.
E/Intercom( 7143): Api call failed: {"error":"Forbidden request"}
Intercom version is intercom_flutter: ^8.0.3 Here is my Flutter Doctor -v output
Flutter (Channel stable, 3.16.1, on macOS 14.1.2 23B92 darwin-arm64, locale en-GB)
• Flutter version 3.16.1 on channel stable at /Users/waheed/developer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7f20e5d18c (5 weeks ago), 2023-11-27 09:47:30 -0800
• Engine revision 22b600f240
• Dart version 3.2.1
• DevTools version 2.28.3
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/waheed/Library/Android/sdk
• Platform android-34, build-tools 31.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A507
• CocoaPods version 1.14.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.3)
• 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.6+0-17.0.6b829.9-10027231)
[✓] VS Code (version 1.84.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.80.0
[✓] Connected device (3 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 12 (API 31)
(emulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.1.2 23B92
darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome
120.0.6099.129
[✓] Network resources
• All expected network resources are available.
• No issues found!
The error in the logs is neither from the loginIdentifiedUser
status callback nor from the catch block
.
Before logging in the user, you are doing the logout. Do you have an Intercom user already logged in at that time?
The error in the logs is neither from the
loginIdentifiedUser
status callback nor from thecatch block
. Before logging in the user, you are doing the logout. Do you have an Intercom user already logged in at that time?
I tried removing the logout part and its still the same error
I'm facing a similar issue, were you able to fix it?
Can you provide reproducible sample?
I was facing a similar problem. The problem was that I was testing between intercom production and test environment and replaced androidApiKey only in one place here await Intercom.instance.initialize('appIdHere', iosApiKey: 'iosKeyHere', androidApiKey: 'androidKeyHere');
but forgot to change it in onCreate()
here IntercomFlutterPlugin.initSdk(this, appId = "appId", androidApiKey = "androidApiKey")
.
In other words, make sure you're using the same androidApiKey in both places - when initiliazing it in onCreate()
and in your flutter code.
Hey I had the same issue earlier and it turns out I have not enabled this option from Intercom Dashboard under Messenger/Install. Not sure if this will help you but it resolved the issue for me. Best.