-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Intercom not initialized crash #4542
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,26 +11,31 @@ class IntercomManager { | |
| static IntercomManager get instance => _instance; | ||
| static final SharedPreferencesUtil _preferences = SharedPreferencesUtil(); | ||
|
|
||
| bool _initialized = false; | ||
|
|
||
| IntercomManager._internal(); | ||
|
|
||
| Intercom get intercom => Intercom.instance; | ||
| bool get _isIntercomEnabled => | ||
| PlatformService.isIntercomSupported && (Env.intercomAppId != null && Env.intercomAppId!.isNotEmpty); | ||
| _initialized && | ||
| PlatformService.isIntercomSupported && | ||
| (Env.intercomAppId != null && Env.intercomAppId!.isNotEmpty); | ||
|
|
||
| factory IntercomManager() { | ||
| return _instance; | ||
| } | ||
|
|
||
| Future<void> initIntercom() async { | ||
| if (Env.intercomAppId == null) return; | ||
| return PlatformService.executeIfSupportedAsync( | ||
| _isIntercomEnabled, | ||
| await PlatformService.executeIfSupportedAsync( | ||
| PlatformService.isIntercomSupported && (Env.intercomAppId != null && Env.intercomAppId!.isNotEmpty), | ||
| () => intercom.initialize( | ||
| Env.intercomAppId!, | ||
| iosApiKey: Env.intercomIOSApiKey, | ||
| androidApiKey: Env.intercomAndroidApiKey, | ||
| ), | ||
| ); | ||
| _initialized = true; | ||
| } | ||
|
Comment on lines
28
to
47
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The early return on line 29 if The check for |
||
|
|
||
| Future displayChargingArticle(String device) async { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve readability and avoid duplicating logic, consider extracting the condition for whether Intercom is configured into its own private getter. This condition is used here and also in
initIntercom.You would then also use
_isIntercomConfiguredinsideinitIntercom.