helpcrunch / android-sdk-demo

Public demo for HelpCrunch Android SDK
Apache License 2.0
9 stars 1 forks source link

Customize Push notifications #60

Closed francescogatto closed 2 years ago

francescogatto commented 2 years ago

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,

TalbotGooday commented 2 years ago

You can intercept push messages and show any notification you want

TalbotGooday commented 2 years ago

@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

francescogatto commented 2 years ago

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..

francescogatto commented 2 years ago

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

francescogatto commented 2 years ago

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

TalbotGooday commented 2 years ago

@francescogatto everything worked out?

francescogatto commented 2 years ago

Yes!

TalbotGooday commented 2 years ago

Cool! I'm glad :+1: