Localytics App Inbox allows you to stream personalized content directly to a dedicated inbox inside of your app.
You may want a user who opens a push message to be redirected to a specific message in their Inbox.
In order to do so, you would:
- First, create and activate your Inbox campaign. It is beneficial to go live with the Inbox campaign well in advance of the push campaign so that it may transmit to end-users’ devices before they receive the Push message.
- Then, create a Push campaign with a deep link targeting the campaign ID associated with the Inbox campaign.
- The deep link should follow the format:
yourapp://inbox?campaign_id=1234 - Finally, go live with the push campaign.
Code samples to retrieve a detail inbox view from the URL may be found below:
iOS
//Code should be in AppDelegate deeplinking methods.
//expected deeplink: yourapp://inbox?campaign_id=1234
NSString *query = url.query;
NSArray *queryComponents = [url.query componentsSeparatedByString:@"&"];
NSInteger campaignId = -1;
for (NSString *keyValuePair in queryComponents) {
NSArray *keyValuePairComponents = [keyValuePair componentsSeparatedByString:@"="];
if ([[keyValuePairComponents objectAtIndex:0] isEqualToString:@"campaign_id"]) {
if(keyValuePairComponents.count == 2) {
campaignId = [[[keyValuePairComponents objectAtIndex:1] stringByRemovingPercentEncoding] integerValue];
break;
}
}
}
if (campaignId > 0) {
[Localytics refreshInboxCampaigns:^(NSArray<LLInboxCampaign *> * _Nullable inboxCampaigns) {
for (LLInboxCampaign *campaign in inboxCampaigns) {
if (campaign.campaignId == campaignId) {
LLInboxDetailViewController *inboxDetailViewController = [Localytics inboxDetailViewControllerForCampaign:campaign];
//present the inboxDetailViewController
}
}
}];
}
Android
//Code should be in Activity#onResume and Activity#onNewIntent
//expected deeplink: yourapp://inbox?campaign_id=1234
Uri deeplink = intent.getData();
if (deeplink != null) {
String campaignIdString = deeplink.getQueryParameter("campaign_id");
if (campaignIdString != null) {
final int campaignId = Integer.parseInt(campaignIdString);
Localytics.refreshInboxCampaigns(new InboxRefreshListener() {
@Override
public void localyticsRefreshedInboxCampaigns(final List<InboxCampaign> campaigns) {
for (InboxCampaign campaign : campaigns) {
if (campaign.getCampaignId() == campaignId) {
InboxDetailFragment fragment = InboxDetailFragment.newInstance(campaign);
//display the fragment
}
}
}
});
}
}
Please note that using any deep link relies on the app developer having encoded logic into the app that understands the keys (eg. “Inbox” and “campaign_ID”) and how to handle the values appropriately. Additionally, the code samples listed don’t take into account any sort of navigation stack, and your developer may prefer to setup something to improve the flow within the app.