To help target specific devices or users for a notification, we have Tags, Named Users and Tag Groups.
Tags are an easy way to group channels. Many tags can be applied to one or
more devices. Then, a message sent to a tag will be sent out to all devices that
are associated with that tag. After modifying tags, make sure to call
to have the SDK sync the tags with Airship.
// Set tags Airship.Instance.EditDeviceTags() .SetTags(["one", "two", "three"]) .Apply(); // Add a tag Airship.Instance.EditDeviceTags() .AddTag("a_tag") .Apply(); // Remove a tag Airship.Instance.EditDeviceTags() .RemoveTag("a_tag") .Apply();
Associating the channel with a Named User ID will implicitly disassociate the channel from the previously associated Named User ID, if an association existed.
Named Users allow you to associate multiple devices to a single user or profile that may be associated with more than one device, e.g., an end-user's iPhone and iPad. A device can have only one Named User, and a single Named User should not be associated with more than 50 devices. Named Users provide the ability to directly set tags on them (see Tag Groups).
UAirship.namedUser().identifier = "NamedUserID"
By default, Named Users can only be associated server-side. A 403 Forbidden response is returned if Named User association is attempted when client-side association is disabled. In order to associate a Named User through the application, you must change the application's Named User security setting to allow Named Users to be set from devices. To enable this option, go to Settings » APIs & Integrations » Named Users.
If setting channel tags is enabled on the device, the predefined
Group cannot be modified from the device and will log an error message. Disable
channel tags by disabling
channelTagRegistrationEnabled on the UAPush instance
if you want to modify this "default" Tag Group.
Tag groups are configurable namespaces for organizing tags for the channel and Named User. Please view the Tag Groups documentation for more details. The Create and push to a tag group guides you through creating and using Tag Groups.
/// Add tags to a group Airship.Instance.EditChannelTagGroups() .AddTags(["silver-member", "gold-member"], "loyalty") .Apply(); // Remove tags from a group Airship.Instance.EditChannelTagGroups() .RemoveTags(["bronze-member", "club-member"], "loyalty") .Apply(); // Set tags on a group Airship.Instance.EditChannelTagGroups() .SetTags(["bingo"], group:"games") .Apply();
// Add tags to a group Airship.Instance.EditNamedUserTagGroups() .AddTags(["silver-member", "gold-member"], "loyalty") .Apply(); // Remove tags from a group Airship.Instance.EditNamedUserTagGroups() .RemoveTags(["bronze-member", "club-member"], "loyalty") .Apply(); // Set tags on a group Airship.Instance.EditNamedUserTagGroups() .SetTags(["bingo"], group:"games") .Apply();
By default, Tag Groups can only be modified from the server. A 403 Forbidden response is returned if Tag Groups modification is attempted when client-side Tag Groups is disabled. In order to modify Tag Groups through the application, you must change the application's Tag Group security settings to allow these tags to be set from devices. Follow the steps in Manage Tag Groups to enable this option.
Airship Channel IDs
The Channel ID is a unique identifier that ties together an application/device pair on iOS devices. The Channel ID is used to target pushes to specific devices using the Airship API.
The Channel ID will be logged for all apps. You can get the channelID by adding one extra line to your application:
string channelId = UAirship.Push().ChannelID;
string channelId = UAirship.Shared().PushManager.ChannelId;
string channelId = Airship.Instance.ChannelId;
Don't worry if this value initially comes back as null on your app's first run (or after clearing the application data), as the Channel ID will be created and persisted during registration.