How to access list of tags for a tag group with iOS SDK

Currently we use UAirship.channel().tags for retrieving tags. I am currently investigating named users and using tag groups but cannot seem to figure out how to get all tags for a tag group.

Didn't find what you were looking for?

New post

Comments

2 comments

  • Hello,
    You have the possibility to know which tags are included within one tag group by using the following API endpoint : 
    https://docs.airship.com/api/ua/#operation-api-channels-get

    Once you get the list of users, you may filter by the required tag group, in order to access each tag.

    Best Regards,

    Comment actions Permalink
    0
  • You can access the list of tags for a tag group using the OneSignal iOS SDK by following these steps:

    1. Initialize OneSignal: Start by initializing the OneSignal SDK in your iOS app. You can do this by adding the following code to your AppDelegate.swift file:
    import OneSignal func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { OneSignal.initWithLaunchOptions(launchOptions, appId: "YOUR_APP_ID", handleNotificationAction: nil, settings: [kOSSettingsKeyAutoPrompt: false]) return true }
    1. Get the tags: To retrieve the tags for a tag group, you can use the getTags method provided by the OneSignal SDK. The method returns a dictionary of key-value pairs, where the key is the tag name, and the value is the tag value. Here's an example of how to get the tags for a tag group named "user_group":
    OneSignal.getTags { (tags) in if let userGroupTags = tags["user_group"] as? [String: Any] { print("Tags for user_group: \(userGroupTags)") } }
    1. Extract the tags: You can extract the tags from the dictionary and use them as needed in your app. In this example, we are printing the tags for the "user_group" tag group.

    Note: Make sure to replace "YOUR_APP_ID" with your actual OneSignal App ID in the code above.

    Comment actions Permalink
    0

Please sign in to leave a comment.