-
Notifications
You must be signed in to change notification settings - Fork 86
bring back firebase, fix android push notifications #124
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
base: master
Are you sure you want to change the base?
Changes from all commits
6873901
940d655
0fe8b41
f73c7f9
9c78c49
3a75de5
84f7039
19a2ea7
dd2a0ad
f6cff2b
0e4b3ee
a983921
158e86e
0b2bc99
8fa60c8
a5e3a21
7aec854
dbcca28
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 |
|---|---|---|
| @@ -1,5 +1,12 @@ | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| > | ||
| <application> | ||
|
Member
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. same here, you should be able to define this in your app layer, not in the plugin. |
||
| <service android:name="com.getcapacitor.community.intercom.intercom.MessagingService" android:exported="false"> | ||
| <intent-filter> | ||
| <action android:name="com.google.firebase.MESSAGING_EVENT" /> | ||
| </intent-filter> | ||
| </service> | ||
| </application> | ||
| <uses-permission android:name="android.permission.INTERNET"/> | ||
| <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> | ||
| <uses-permission android:name="android.permission.VIBRATE"/> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package com.getcapacitor.community.intercom; | ||
| package com.getcapacitor.community.intercom.intercom; | ||
|
|
||
| import android.app.Activity; | ||
| import android.app.Application; | ||
|
|
@@ -219,8 +219,12 @@ public void displayCarousel(PluginCall call) { | |
| @PluginMethod | ||
| public void setUserHash(PluginCall call) { | ||
| String hmac = call.getString("hmac"); | ||
| Intercom.client().setUserHash(hmac); | ||
| call.resolve(); | ||
| try { | ||
| Intercom.client().setUserHash(hmac); | ||
| call.resolve(); | ||
| } catch (Exception e) { | ||
| call.reject("Failed to send user hash to Intercom", e); | ||
| } | ||
| } | ||
|
|
||
| @PluginMethod | ||
|
|
@@ -272,6 +276,17 @@ private void setUpIntercom() { | |
| String apiKey = config.getPluginConfiguration("Intercom").getString("androidApiKey"); | ||
| String appId = config.getPluginConfiguration("Intercom").getString("androidAppId"); | ||
|
|
||
| switch (IntercomPushManager.getInstalledModuleType()) { | ||
|
Member
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. not sure about this part as I can't test. but do we really need to tell Intercom to cache a sender id? if so, something to investigate and move to the app layer as well. |
||
| case FCM: { | ||
| String senderId = config.getPluginConfiguration("Intercom").getString("senderId"); | ||
| // with FCM enabled, a senderId can be provided | ||
| if(!senderId.isEmpty()) { | ||
| IntercomPushManager.cacheSenderId(this.getActivity().getApplicationContext(), senderId); | ||
| } | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| // init intercom sdk | ||
| Intercom.initialize(this.getActivity().getApplication(), apiKey, appId); | ||
| } catch (Exception e) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package com.getcapacitor.community.intercom.intercom; | ||
|
Member
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. this MessagingService could be implemented in the MainActivity if using the app's AndroidManifest |
||
|
|
||
| import androidx.annotation.NonNull; | ||
|
|
||
| import com.google.firebase.messaging.FirebaseMessagingService; | ||
| import com.google.firebase.messaging.RemoteMessage; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import io.intercom.android.sdk.push.IntercomPushClient; | ||
|
|
||
| public class MessagingService extends FirebaseMessagingService { | ||
| private final IntercomPushClient intercomPushClient = new IntercomPushClient(); | ||
| @Override | ||
| public void onMessageReceived(RemoteMessage message) { | ||
| Map messageData = message.getData(); | ||
| if (intercomPushClient.isIntercomPush(messageData)) { | ||
| intercomPushClient.handlePush(getApplication(), messageData); | ||
| } else { | ||
| super.onMessageReceived(message); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onNewToken(@NonNull String s) { | ||
| super.onNewToken(s); | ||
| intercomPushClient.sendTokenToIntercom(this.getApplication(), s); | ||
| } | ||
| } | ||
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.
@jpike88 have you tried defining the firebase-messaging dep in your app's build.gradle instead ?