Messaging using huge amount of data?


private func subscribe() {
 let subscriptionOptions = SubscriptionOptions()
 
 appDelegate.backendless.messagingService.subscribe(SYNC_CHANNEL,
 subscriptionResponse: {(response : [AnyObject]!) -> () in
 print ("response")
 
 let messages : [AnyObject] = response
 
 for object in messages {
 if object is Message {
 let message = object as! Message
 print ("message: \(message)")
 }
 }
 
 },
 subscriptionError: { (fault : Fault!) -> () in
 print("Messaging Error (ASYNC): \(fault)")
 },
 subscriptionOptions: subscriptionOptions)
 }

Using the above code while the app is running it is using a lot of data while idling, caused by the polling. Is there a way to limit the data usage?

I just want to notify subscribers that there are updates queued (objects to be fetched), so the app doesn’t need to poll all the time to check for queued objects. However using it this way uses way too much data.

Any suggestions?

1 Like

Hi Barry,

As much fun as it is to read other people’s code, it would be awesome if you could also describe the problem in English. Would you please? ))

Regards,
Mark

hahaha: I was still editing my post. The problem is that when using the code button in the wysiwyg editor, then I first need to hit comment and edit the post again to get ‘out of the code block’ (if that makes any sense).

PS: Using Safari 9.0.2

Using instruments it shows 1.5KB/s (KiloByte that is). That is without sending/receiving actual messages, purely while the app is idling / in use.

Hi Barry,

The traffic is due to polling requests made by the device. You can control the frequency using the following property:
https://github.com/Backendless/ios-SDK/blob/master/SDK/osx/backendless/include/MessagingService.h#L60

Also, we will be providing an enhancement soon that would allow you to avoid polling completely as the messages will be delivered via silent push notifications.

Regards,
Mark

Hi Mark,

Great news about the silent push notifications.

I did already see the interval property, but setting that to lower intervals would make the app ‘less-live’.

Anyway: For now the polling is fine (in dev environment), I’ll switch to the silent pushing method as soon as it is available.