How to hold Xtify subscription till successful login and users acceptance for registration

58 views Asked by At

Objective is to implement push subscription by using Xtify SDK in iOS and Android apps. The other requirement is that subscription should happen to Xtify only if user has done successful login and users agreement to subscription (not before that). But the problem is that in Xtify SDK I don't find any explicit subscription method and it appears that subscription happens automatically at the time when app gets loaded for the first time. I want to control this behavior and want to call subscription only after successful login and users acceptance (via js popup) that he wants to register (or not) to Xtify notifications. Based on his response, I'll decide whether to subscribe to Xtify or not.

Requirement is XID should not be generated till the time login is successful and user has accepted some terms & condition after that.

Please let me know SDK subscription method where I can decide when to call.

App details:

  • IBM Worklight 6.2 Hybrid app
  • Environments: Android and iOS
2

There are 2 answers

1
Gilad M On

For iOS, you will need to move Xtify initialization code to the login section. In particular move the following code to the desire place:

    XLXtifyOptions *anXtifyOptions=[XLXtifyOptions getXtifyOptions];
    anXtifyOptions.categories = [self getDeveloperPushCategories]; // use this method to enable static categories
    [[XLappMgr get ]initilizeXoptions:anXtifyOptions];

For Android, you'll need to move initialization, see below, from MainActivity::onStart() to the desire place:

    XtifySDK.start(getApplicationContext(), XTIFY_APP_KEY, PROJECT_NUM);
0
user3486184 On

One option may be to set a tag by calling the tagging API on the device for users who have successfully subscribed. Then in your campaigns, ensure you have a tag rule that sends only to users who have that tag.

On iOS, I think this would be:

[[XLappMgr get] addTag: @[@"subscribed"];

On Android,

XtifySDK.addTag(context, "subscribed")

You'd then implement a tag rule in the console to send only to users who had the "subscribed" tag.