Skip to main content

We have a push notification settings screen in our app where users can fine tune the types of push notification they can receive. We want someone to be able to turn off just intercom push notifications if they so desire. Once you called Intercom.setDeviceToken(deviceToken), is it not possible to change your mind and remove your device from intercom push notifications?

I also don't want to use Intercom.logout() since we still want to allow the user to be able to do in app chat.

Hey @sebastien​! There isn't a way to do that at the moment, and I've taken a note of your feedback. There's a couple of things you could consider..

 

How well these work will depend on whether you're just using push notifications for conversation replies, or whether you're sending outbound push messages as well.

 

If you handle the push notifications manually, you can decide whether they should be shown to your customers or not. Push notifications docs for that are here for Android and here for iOS. For example, for Android, you could use something like this to stop push notifications being shown:

 

if (intercomPushClient.isIntercomPush(message)) {

if (shouldShowIntercomPush) { intercomPushClient.handlePush(getApplication(), message);}

} else {

//DO HOST LOGIC HERE

}

 

Another option, which is more relevant for outbound push messages (ie. it won't affect notifications for conversation replies), would be to set a custom attribute on the user in Intercom (eg. push_opted_out) and use that as a filter in your audience rules for outbound push messages. This is less elegant, as it'll require you to remember to use the filter every time.

 

The third option, which you've already suggested isn't practical for your use case, would be to log the user out of Intercom. I understand why that doesn't work for the use case you're describing, though.

 

Hope that helps, and thank you for the feedback! Let me know if you have any follow up questions.


Ok thank you for the answer.

 

Just a note though

 

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {

 

is not involved in deciding wether the system should show an inbound notification or not. This method is called after you tap on the system notification banner that triggers the app to be launched or foregrounded. An iOS app has no way to do this kind of filtering.

 

actually a question for you, if I call Intercom.logout() and then Intercom.registerUser() right back without ever resending a new push notification token, would that work? In another word on logout() do you just flag off push notification sending or do you completely delete the push notification token?


That would work, but there's one thing to note. There's some protection in the mobile SDKs that delays the logout request for a few milliseconds, so calling logout and then register immediately afterwards wouldn't have the desired effect. You'd need a delay between the two calls for it to be effective.


Picking this up as I have a similar requirement. I note in your Android SDK there is an API method: removeDeviceToken - can this not be used ?


Reply