@capacitor-community/intercom
Capacitor community plugin for enabling Intercom capabilities
Intenseloop |
Maintainer | GitHub | Social |
---|---|---|
Stewan Silva | stewones | @stewones |
We're starting fresh under an official org. If you were using the previous npm package capacitor-intercom
, please update your package.json to @capacitor-community/intercom
. Check out changelog for more info.
Using npm:
npm install @capacitor-community/intercom
npm install https://github.com/amalinvest/intercom --save
Using yarn:
yarn add @capacitor-community/intercom
yarn add https://github.com/amalinvest/intercom
Sync native files:
npx cap sync
- registerIdentifiedUser
- registerUnidentifiedUser
- updateUser
- logout
- logEvent
- displayMessenger
- displayMessageComposer
- displayHelpCenter
- hideMessenger
- displayLauncher
- hideLauncher
- displayInAppMessages
- hideInAppMessages
- displayCarousel
- setUserHash
- setBottomPadding
import { Intercom } from '@capacitor-community/intercom';
import { PushNotifications } from '@capacitor/push-notifications';
// Register for push notifications from Intercom
PushNotifications.register();
// Register an indetified user
Intercom.registerIdentifiedUser({ userId: 123456 });
Intercom.registerIdentifiedUser({ email: '[email protected]' });
Intercom.registerIdentifiedUser({ userId: 123456, email: '[email protected]' });
// Register a log event
Intercom.logEvent({ name: 'my-event', data: { pi: 3.14 } });
// Display the message composer
Intercom.displayMessageComposer({ message: 'Hello there!' });
// Identity Verification
// https://developers.intercom.com/installing-intercom/docs/ios-identity-verification
Intercom.setUserHash({ hmac: 'xyz' });
- add intercom keys to capacitor's configuration file
{
β¦
"plugins": {
"Intercom": {
"iosApiKey": "ios_sdk-xxx",
"iosAppId": "yyy"
}
}
β¦
}
npx cap run ios
Tip: every time you change a native code you may need to clean up the cache (Product > Clean build folder) and then run the app again.
- Add intercom keys to capacitor's configuration file
{
β¦
"plugins": {
"Intercom": {
"androidApiKey": "android_sdk-xxx",
"androidAppId": "yyy"
}
}
β¦
}
npx cap run android
Now you should be set to go. Try to run your client using ionic cap run android --livereload
.
Tip: every time you change a native code you may need to clean up the cache (Build > Clean Project | Build > Rebuild Project) and then run the app again.
- Add this dependecy to
android/app/build.gradle
dependencies {
implementation 'com.google.firebase:firebase-messaging:20.2.+'
}
- Create a new file
android/app/src/main/java/com/YOUR_APP/PushNotificationService.java
that extendsFirebaseMesssagingService
if you dont have one already.
package com.YOUR_APP;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.getcapacitor.community.intercom.IntercomPlugin;
public class PushNotificationService extends FirebaseMessagingService {
@Override
public void onNewToken(String refreshedToken) {
IntercomPlugin.sendTokenToIntercom(getApplication(), refreshedToken);
}
public void onMessageReceived(RemoteMessage remoteMessage) {
if (IntercomPlugin.isIntercomPush(remoteMessage)) {
IntercomPlugin.handleRemotePushMessage(getApplication(), remoteMessage);
}
}
}
- Then add the following code to
android/app/src/main/AndroidManifest.xml
<service
android:name=".PushNotificationService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
MIT
Thanks goes to these wonderful people (emoji key):
Stew π» π |
David Seek π» |
Roman Nikitin π» |
Anne Tomassoni π» π |
Maciej Modzelewski π» |
Oleg Yuzvik π§ |
Gustavo CorrΓͺa Alves π |
Jealvia π§ |
Adam Duren π» π§ |
This project follows the all-contributors specification. Contributions of any kind welcome!