Here are some use cases of how tags can be useful: 

  • A news app will use tags to send fashion news to only those who are interested in fashion, and politics to those who are interested in politics. 

  • A food app can send certain deals to those who like burger and meat. 

  • A travel app might have have a tag for each country so that it can send promotions based on users preferences for destinations. 

Steps

Note:

  • The code will be in swift 3 and Objective c.

  • This Guide supposes you're implementing PushBots In your app and everything works fine, if not Check here.

  • This guided suppose user will be logged in within your app.

Add UISwitch to your Settings ViewController

Hook up your switch to your ViewController class file

Add those lines to your code :

Swift :

 @IBAction func subscribeSwitchValueChanged(_ sender: Any) {

    if sampleSwitch.isOn {
    print("ON")
    //subscribe to your newsletters
    Pushbots.sharedInstance().tag(["**NewsLetterTag**"]));
   }
else {
    print ("OFF")
    //Unsubscribe to from newsletters
    Pushbots.sharedInstance().untag(["**NewsLetterTag**"]);

  }
}

Objectice C :

- (IBAction)subscribeSwitch:(UISwitch *)sender {

      if (sender.isOn) {
         //subscribe to your newsletters
        [self.PushbotsClient tag:@[@"**NewsLetterTag**"]];;

      }else{
         //unsubscribe to your newsletters
        [self.PushbotsClient untag:@[@"**NewsLetterTag**"]];
    }
  }

You can send to a specific user via PushBots Dashboard:

It is so easy, Right? 👍

Note: You can find more information:

Did this answer your question?