Unregister User from Channel

I’m trying to enable an option in the app where the user can opt out of receiving a certain type of notifications. I understand from what I’ve read on the support forum that there is not way to unregister a user from a particular channel (I also didn’t find such a method). However, you can unregister the device, which will unregister all the channels, and then register back the other channels.

I tried just that but I’m having issues with it and I would appreciate some help. The problems appear when I’m trying to register the user to the other channels. Btw, I’m using Swift.

If I use the following lines:
Backendless.sharedInstance().messaging.registerForRemoteNotifications()
Backendless.sharedInstance().messagingService.registerDevice([])
The user will get subscribed to all channels (which I don’t want - I only want it to subscribe to the channels in the list)

If I don’t use the above line and instead use only:
Backendless.sharedInstance().messagingService.registerDevice([])

The user appears to be subscribed for the right channels but no push notifications are reaching the device.

Is there a way to achieve what I want? If so, what am I missing?
Thanks.

Hi Florin,

Recently MessagingService API was refactored:

Please investigate our PushNotify sample - how it is organized.
Pay your attention to OLD marker - it shows the difference between old and new implementations.

We are going to change our documentation in this section asap. We will let you know about.

Regards,
Slava

Thanks for your answer.

I did try the new method:
Backendless.sharedInstance().messaging.startupRegisterDeviceWithChannels([])

But the same thing is happening. The device is registered to all channels, instead of those provided in the list.

Ok, Florin, we will check this issue

Florin,

May I ask how you verified that the device is registered for all channels?

Also, the new “startupRegisterDeviceWithChannels” API may change. The final version will be available from our website - the version in github is not considered final.

Mark

First, after re-registering using a limited list of channels, the device would receive notifications from all channels.

Second, by looking at Messaging and checking the devices registered for each channel.

Florin,

We cannot reproduce this issue. When device is registered in the “second” channel group, it is removed from the “first” channel group.

Please remove all registration for all your devices which you use in this test, and try again.

I tried everything that I could think of, again. Including deleting all registrations and all channels. It does not work. It’s either both channels or none.

Moreover, if I go to backendless.com - messaging and delete a device from a channel, it automatically gets deleted from the other. This shouldn’t be happening, right?