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

feat: Add Push Primer feature using Custom Json (RMCCX-6702) #322

Merged
merged 15 commits into from
Aug 6, 2024

Conversation

SoumenRautray
Copy link
Contributor

@SoumenRautray SoumenRautray commented Jul 16, 2024

Description

Added PushPrimer feature using Custom JSON
Added functionality to navigate to settings when authorization is previously denied
Added check for not displaying campaign if authorization is previously allowed
Added check for displaying Push Primer campaigns only for RMC users

Links

[RMCCX-6702]

Checklist

  • I have read the contributing guidelines
  • I have added to the changelog
  • I wrote/updated tests for new/changed code
  • I removed all sensitive data before every commit, including API endpoints and keys, and internal links
  • I ran fastlane ci without errors
  • All project file changes are replicated in SampleSPM/SampleSPM.xcodeproj project

@rakutentech-danger-bot
Copy link
Collaborator

rakutentech-danger-bot commented Jul 18, 2024

18 Warnings
⚠️ This PR does not have any assignees yet
⚠️ Branch name "RMCCX-6702_CustomJson" should match format: <type>/<ticket-no>_<short-desc> or <type>/<short-desc> or release/<version or desc>
⚠️ Verb "tes" in the commit message must be in imperative tense
⚠️ Commit message "chore: test case refactor (RMCCX-6702)" should append ticket number(s) e.g. (SDKCF-1234, SDKCF-1235)
⚠️ Commit message "chore: Fix Test case failures (RMCCX-6702)" should append ticket number(s) e.g. (SDKCF-1234, SDKCF-1235)
⚠️ Verb "addres" in the commit message must be in imperative tense
⚠️ Commit message "chore: address review comments, refactor code and test cases (RMCCX-6702)" should append ticket number(s) e.g. (SDKCF-1234, SDKCF-1235)
⚠️ Commit message "chore: add changeLog changes (RMCCX-6702)" should append ticket number(s) e.g. (SDKCF-1234, SDKCF-1235)
⚠️ Commit message "chore: refactor code and add new test cases (RMCCX-6702)" should append ticket number(s) e.g. (SDKCF-1234, SDKCF-1235)
⚠️ Commit message "chore: disable pushprimer campaign for IAM (RMCCX-6702)" should append ticket number(s) e.g. (SDKCF-1234, SDKCF-1235)
⚠️ Commit message "chore: code refactor (RMCCX-6702)" should append ticket number(s) e.g. (SDKCF-1234, SDKCF-1235)
⚠️ Commit message "chore: add test cases for push Primer (RMCCX-6702)" should append ticket number(s) e.g. (SDKCF-1234, SDKCF-1235)
⚠️ Commit message "chore: add check for enabling pushPrimer only for RMC (RMCCX-6702)" should append ticket number(s) e.g. (SDKCF-1234, SDKCF-1235)
⚠️ Commit message "chore: refactor code (RMCCX-6702)" should append ticket number(s) e.g. (SDKCF-1234, SDKCF-1235)
⚠️ Commit message "chore: address review comments (RMCCX-6702)" should append ticket number(s) e.g. (SDKCF-1234, SDKCF-1235)
⚠️ Commit message "chore: fix CI error (RMCCX-6702)" should append ticket number(s) e.g. (SDKCF-1234, SDKCF-1235)
⚠️ Commit message "chore: update test cases (RMCCX-6702)" should append ticket number(s) e.g. (SDKCF-1234, SDKCF-1235)
⚠️ Commit message "chore: Add Push Primer feature using Custom Json (RMCCX-6702)" should append ticket number(s) e.g. (SDKCF-1234, SDKCF-1235)

Current coverage for RInAppMessaging.framework is 90.13%

Files changed - -
UIApplication+IAM.swift 89.06%
CampaignsValidator.swift 94.62%
FullViewPresenter.swift 96.35%
CampaignData.swift 100.00%
CampaignDataModels.swift 100.00%
MainContainer.swift 100.00%
Campaign.swift 100.00%

Powered by xcov

Generated by 🚫 Danger

Copy link
Contributor

@Esakkiraja-Pothikannan Esakkiraja-Pothikannan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please add test cases to validate new push primer implementation
  • What about legacy dashboard push primer functionality? Would those implementation work / valid?

return nil
}()

private static let appNotificationSettingsURL = URL(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be method property of func openAppNotificationSettings(). No need of having static property so that you can do nil check for notificationSettingsURLString instead of assigning empty string.

string: notificationSettingsURLString ?? ""
)

func openAppNotificationSettings() -> Void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: -> Void not required to be mentioned.

@@ -56,16 +56,17 @@ internal class FullViewPresenter: BaseViewPresenter, FullViewPresenterType, Erro

func loadButtons() {
let buttonList = campaign.data.messagePayload.messageSettings.controlSettings.buttons

let pushPrimerButton = campaign.data.customJson?.pushPrimer?.button ?? nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? nil is not need if it can accept nil & no need any default value.

urlString = UIApplicationOpenNotificationSettingsURLString
} else if #available(iOS 8.0, *) {
urlString = UIApplication.openSettingsURLString
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else part is not required.

@@ -32,7 +32,7 @@ internal struct Campaign: Codable, Hashable {
}.filter { !$0.isEmpty }
}
var isPushPrimer: Bool {
return data.customJson?.pushPrimer?.button != nil
return RInAppMessaging.isRMCEnvironment && data.customJson?.pushPrimer?.button != nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change property name else move the RMC environment check to different place

let semaphore = DispatchSemaphore(value: 0)
var authorizationStatus: UNAuthorizationStatus = .notDetermined

let center = UNUserNotificationCenter.current()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inject the UNUserNotificationCenter with custom protocol to test these feature

@@ -658,6 +658,85 @@ class ViewPresenterSpec: QuickSpec {
expect(impressionService.sentImpressions?.list).toNot(contain(.optOut))
}
}
context("when custom json data is available in Campaign Data") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the description to mention "when push primer content available" context.

@@ -90,4 +103,22 @@ internal struct CampaignsValidator: CampaignsValidatorType {

return triggeredEvents
}

internal func isNotificationAuthorized() -> Bool {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default func is internal, no need to specify explicitly

@@ -21,3 +21,27 @@ extension UNUserNotificationCenter: RemoteNotificationRequestable {
}
}
}

protocol UserNotificationCenter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make use of RemoteNotificationRequestable & follow the implementation of that

authorizationStatus = settings.authorizationStatus
semaphore.signal()
}
semaphore.wait()

return authorizationStatus == .authorized
switch authorizationStatus {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to previous implementation where it was relay on .authorized else it wouldn't work when status was provisional.

Copy link

sonarcloud bot commented Aug 6, 2024

@SoumenRautray SoumenRautray merged commit 58c4ff4 into rakutentech:master Aug 6, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants