Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CT Push Migration #522

Merged
merged 2 commits into from
Oct 12, 2022
Merged

CT Push Migration #522

merged 2 commits into from
Oct 12, 2022

Conversation

nzagorchev
Copy link
Contributor

@nzagorchev nzagorchev commented Oct 12, 2022

What Where/Who
JIRA Issue SDK-2316
People Involved @nzagorchev

Background

Support Notifications from both Leanplum and CleverTap

CT swizzling is not called (no swizzling of iOS delegate methods) when using a custom instance and the method is internal.
Instead of using double swizzling, check if the notification comes from Leanplum and if not, forward it to CleverTap to handle it using the CleverTap.handlePushNotification method.

Implementation

Create a new NotificationsManager that inherits from it and handles both CT and LP notifications. Override the push receive and open methods. Call the corresponding SDK based on the push payload. Handle registration with a device token as well.

For CT, ensure that CleverTap.handlePushNotification and CleverTap.setPushToken methods are called once we have an instance initialized.
Set the push token when the CT instance is initialized, based on the token cached by Leanplum, using instance.setPushTokenAs.

The Leanplum Notifications Object is also modified to not filter out the notifications. This logic is moved to the NotificationsManager.

Note that CT does not send the "content-available" flag, so the app will not be woken up by a CT notification.

Example payloads

Leanplum

{
   "_lpn":5187874616049123,
   "aps":{
      "alert =""Push message goes here.",
      "content-available"= 1,
      "mutable-content"= 1
   },
   "_lpx":{
      "__name__""="""
   },
   "LP_URL":"https":,
   "apns-push-type":"alert"
}

CleverTap

{
   "W$rnv":0,
   "wzrk_dl":"https":,
   "W$pivot":"wzrk_default",
   "ct_mediaType":"image",
   "wzrk_acct_id":W84-WW7-123A,
   "ct_mediaUrl":"https"://db7hsdc8829us.cloudfront.net/...,
   "W$dt":"APPLE",
   "W$id":0_0,
   "aps":{
      "alert ="{
         "body = message",
         "title = hello"
      };
    badge = 3,
      "mutable-content"= 1
   }
}

Testing steps

Testing Push is received and opened when:

  • the app is not running
  • the app is not running, and the app is woken up by push (Background Mode: Remote notification)
  • the app is running in background
  • the app is on foreground

Is this change backwards-compatible?

Yes

@nzagorchev nzagorchev merged commit 7c548de into master Oct 12, 2022
@delete-merged-branch delete-merged-branch bot deleted the migration-push branch October 12, 2022 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants