Step 3.4: Optional SDK methods

Adding Tags

By subscribing to a tag you can create segments and target notifications to your devices subscribed to those tags.

sdk?.subscribeTag(tag: "YourTagHere")

To unsubscribe from a tag

sdk?.unsubscribeTag(tag: "YourTagHere")

Show In-App Notifications (custom triggered)

By calling this method and passing the custom event identifier string as parameter, the app will show any active in-app notification pending in the app.

sdk?.showInAppNotification(with: "YourCustomIdentifierHere")
[sdk showInAppNotificationWith: @"YourCustomIdentifierHere"]

Personalisation

The TENANT_ID will be passed in when the SDK is initialised. Failing to add this parameter would mean that the Personalisation values cannot be set and processed by the SDK.

Where to find the TENANT_ID?

It can be copied from the Notivera portal under the SETTINGS -> API KEYS tab

Methods to set and get the personalisation values.

  1. The below methods are used to set values to existing variables in the local personalisation schema. The local schema will be updated periodically and kept in sync with any variable changes in the Notivera portal. Please note that if the value that you are trying to set is not part of the local schema then this value will be rejected.

To set multiple values

func updatePersonalisationSchema() {
      let schemaArray =
      """
      [{"name":"FirstName","value":"Mark"},{"name":"LastName","value":"Anthony"},{"name":"Key3","value":"Value3"}]
      """
    do {
      let schema = try JSONDecoder().decode([PSDKPersonalisationSchema].self, from: Data(schemaArray.utf8))
      try sdk?.updatePersonalisationVariables(schema: schema)
      let data = sdk?.getAllPersonalisations()
      dump (data)
    } catch {
    }
}
- (void)updatePersonalisationSchemaArray {
    NSString* schemaArray = @"[{\"name\":\"FirstName\",\"value\":\"Mark\"}]";
    NSData* data = [schemaArray dataUsingEncoding: NSUTF8StringEncoding];
    NSArray *jsonArray = (NSArray *)[NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
    [sdk updatePersonalisationVariablesFor:jsonArray error:nil];
    NSArray* getAll = [sdk getAllPersonalisationsLegacy];
    NSLog(@"%@", getAll);
}

To set a single value