How to subscribe multiple topics in "AWSIoT" iOS SDK?

564 Views Asked by At

I am using AWSIoT iOS SDK (version 2.6.0) in my current application.

To subscribe the topic currently, we are using below method of SDK

- (BOOL) subscribeToTopic:(NSString *)topic
                      QoS:(AWSIoTMQTTQoS)qos
          extendedCallback:(AWSIoTMQTTExtendedNewMessageBlock)callback

Can you please let me know how can we subscribe to multiple topics with the single method call?

Thanks in advance.

2

There are 2 best solutions below

1
On

Will not work out by calling one method subscribe on one topics. Use NSNotifacationCenter

0
On

If you want to subscribe to a 'topic tree' i.e. multiple topics, use '+' or '#' E.g., if you have these topics: mydevice/temp/sensor1 mydevice/temp/sensor2 mydevice/humidity/sensor1 mydevice/humidity/sensor2

Subscribing to "mydevice/temp/+" gives you messages from both temp sensors, subscribing to "mydevice/#" gives you all temp and humidity sensors. The '+' is a single level wild card, the '#' a multi-level wild card.