Closed francescogatto closed 2 years ago
You can intercept push messages and show any notification you want
@francescogatto here is an example of custom notification service. Pay attention that you should set some you should set a higher priority to intercept push notifications. For example, 9999 or something like that
I'm trying, but with same implementation of the android sdk example, with 9999 priority, when i send a message, my service is never called from Helpcrunch push notification, but mine yes. On android sdk works..
here my implemementation: In my application i have:
HelpCrunch.initialize(
"Zzzz",
3,
"yyyyy", null
)
manifest:
<service
android:name=".utils.FcmMessageService"
android:exported="true" android:priority="9999">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
my service:
class FcmMessageService : FirebaseMessagingService() {
override fun onNewToken(token: String) {
super.onNewToken(token)
}
override fun onMessageReceived(remoteMessage: RemoteMessage) {
super.onMessageReceived(remoteMessage)
if (HelpCrunchExt.isHelpCrunchMessage(remoteMessage)) {
.... omissis
start sdk:
HelpCrunch.updateUser(
HCUser.Builder()
.withName("1dfewewf")
.withEmail("1efwefwefewf")
.withUserId("ewfwefewfewfef")
.build(), object : Callback<HCUser>(){
override fun onSuccess(p0: HCUser) {
super.onSuccess(p0)
HelpCrunch.showChatScreen(HCOptions.createDefault())
}
override fun onError(message: String) {
super.onError(message)
}
})
But my service is never called
Understood...
this is worng
<service
android:name=".utils.FcmMessageService"
android:exported="true" android:priority="9999">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
the correct is
<service
android:name=".utils.FcmMessageService"
android:exported="true" >
<intent-filter android:priority="9999">
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
Android priority must go on intent filter.. sorry, it was a my error
@francescogatto everything worked out?
Yes!
Cool! I'm glad :+1:
Is it possible to remove "reply" action from the push notification? Is it possible to hide the message chat with default message in the notification?? In my app, people should see and answer only in the app,