User Trigger

Magnet Max offers user trigger capability. Users can define customized rules with actions (e.g., send a message to a specific user) that can be triggered if the time AND/OR location condition is satisfied.

By using User Trigger function, it's easy to achieve the following use cases.

Case 1. A user wants to send a message to anyone in a target group:

  • if target group user(s) are in a specific location AND/OR
  • during a certain timeframe

Case 2. A user wants to get push notifications from anyone in a target group:

  • if the user is in a specific location AND/OR
  • during a certain timeframe

The Magnet Max SDK provides the following APIs to handle the user trigger function.

Create New User Rule

The following creates a new user rule

[MMUserRule createUserRule:userRule success:^(MMUserRule *newRule){ //Success } failure:^(NSError *error) { //Failure }];

Update Existing User Rule

The following updates an existing user rule.

[MMUserRule updateUserRule:userRule success:^(MMUserRule *updatedRule){ //Success } failure:^(NSError *error) { //Failure }];

Delete User Rule

The following deletes an existing user rule

[MMUserRule deleteUserRule:userRuleId success:^ { //Success } failure:^(NSError *error) { //Failure }];

Fetch User Rules

You can retrieve user rules by user or by rule ID.

The following will fetch all existing user rules, which are created by the current user.

[MMUserRule getAllMyRules success:^(NSArray<MMUserRule *> *allRules) { //Success } failure:^(NSError *error) { //Failure }];

The following will fetch a user rule with a specific ID.

[MMUserRule getRuleWithID:userRuleId success:^(MMUserRule *userRule) { //Success } failure:^(NSError *error) { //Failure }];

Trigger Rule Actions

The following notifies the server that rule actions should be triggered (e.g., user location condition in the rule is satisfied).

[UserRule trigger success:^ { //Success } failure:^(NSError *error) { //Failure }];