Skip to content

Commit

Permalink
Merge branch 'rating'
Browse files Browse the repository at this point in the history
  • Loading branch information
thebei3 committed Mar 8, 2024
2 parents 6d31266 + 8c228a1 commit 9a252bf
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 37eb5f3e9a2f3ac48e581d087a56e280a7f7889b

COCOAPODS: 1.15.2
COCOAPODS: 1.12.1
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ class EventViewController: FormViewController, BannerDelegate {
.inappcarousel: [VisilabsInAppNotificationType.inappcarousel.rawValue: 804],
.drawer : [VisilabsInAppNotificationType.drawer.rawValue: 884],
.video : [VisilabsInAppNotificationType.video.rawValue: 73],
.bannerCarousel : [VisilabsInAppNotificationType.bannerCarousel.rawValue: 155]
.bannerCarousel : [VisilabsInAppNotificationType.bannerCarousel.rawValue: 155],
.apprating : [VisilabsInAppNotificationType.apprating.rawValue: 1101]
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ class InAppViewController: FormViewController {
setFormRowsForEmail()
case .bannerCarousel:
break
case .apprating:
break
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public enum VisilabsInAppNotificationType: String, CaseIterable {
case drawer = "drawer"
case video = "video"
case bannerCarousel = "banner_carousel"
case apprating = "MobileAppRating"

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation
import UIKit
import StoreKit

protocol VisilabsInAppNotificationsDelegate: AnyObject {
func notificationDidShow(_ notification: VisilabsInAppNotification)
Expand Down Expand Up @@ -89,6 +90,9 @@ class VisilabsInAppNotifications: VisilabsNotificationViewControllerDelegate {
self.markTargetingActionShown(model: drawer)
}
}
else if model.targetingActionType == .apprating {
self.showInappRating()
}
}
}
}
Expand All @@ -113,6 +117,14 @@ class VisilabsInAppNotifications: VisilabsNotificationViewControllerDelegate {
sideBarViewController.show(animated: true)
return true
}

func showInappRating() {
DispatchQueue.main.async {
if #available(iOS 10.3, *) {
SKStoreReviewController.requestReview()
}
}
}

func showMiniNotification(_ notification: VisilabsInAppNotification) -> Bool {
let miniNotificationVC = VisilabsMiniNotificationViewController(notification: notification)
Expand Down
21 changes: 21 additions & 0 deletions Sources/TargetingAction/InappReviewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// InappReviewModel.swift
// VisilabsIOS
//
// Created by Orhun Akmil on 8.03.2024.
//

import Foundation


struct InappReviewModel : TargetingActionViewModel, Codable {

var targetingActionType: TargetingActionType
var auth: String?
var actId: Int?
var type: String?
var title: String?
var jsContent: String?
var jsonContent: String?

}
1 change: 1 addition & 0 deletions Sources/TargetingAction/TargetingActionViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum TargetingActionType: String, Codable {
case scratchToWin = "ScratchToWin"
case productStatNotifier = "ProductStatNotifier"
case drawer = "Drawer"
case apprating = "MobileAppRating"
}

public protocol TargetingActionViewModel {
Expand Down
14 changes: 12 additions & 2 deletions Sources/TargetingAction/VisilabsTargetingAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class VisilabsTargetingAction {
props[VisilabsConstants.lvtKey] = visilabsUser.lvt


props[VisilabsConstants.actionType] = "\(VisilabsConstants.mailSubscriptionForm)~\(VisilabsConstants.spinToWin)~\(VisilabsConstants.scratchToWin)~\(VisilabsConstants.productStatNotifier)~\(VisilabsConstants.drawer)"
props[VisilabsConstants.actionType] = "\(VisilabsConstants.mailSubscriptionForm)~\(VisilabsConstants.spinToWin)~\(VisilabsConstants.scratchToWin)~\(VisilabsConstants.productStatNotifier)~\(VisilabsConstants.drawer)~\(VisilabsConstants.apprating)"

for (key, value) in VisilabsPersistence.readTargetParameters() {
if !key.isEmptyOrWhitespace && !value.isEmptyOrWhitespace && props[key] == nil {
Expand Down Expand Up @@ -140,7 +140,9 @@ class VisilabsTargetingAction {
return parseScratchToWin(sctw)
} else if let drawerArr = result[VisilabsConstants.drawer] as? [[String: Any?]], let drw = drawerArr.first {
return parseDrawer(drw)
} else if let psnArr = result[VisilabsConstants.productStatNotifier] as? [[String: Any?]], let psn = psnArr.first {
} else if let inappRating = result[VisilabsConstants.apprating] as? [[String: Any?]], let inappRating = inappRating.first {
return parseInappRating(inappRating)
} else if let psnArr = result[VisilabsConstants.productStatNotifier] as? [[String: Any?]], let psn = psnArr.first {
if let productStatNotifier = parseProductStatNotifier(psn) {
if productStatNotifier.attributedString == nil {
return nil
Expand Down Expand Up @@ -282,6 +284,14 @@ class VisilabsTargetingAction {
return model
}

private func parseInappRating(_ inappratingModel: [String: Any?]) -> InappReviewModel? {
guard let actionData = inappratingModel[VisilabsConstants.actionData] as? [String: Any] else { return nil }
var inappRating = InappReviewModel(targetingActionType: .apprating)
inappRating.actId = inappratingModel[VisilabsConstants.actid] as? Int ?? 0
inappRating.title = inappratingModel[VisilabsConstants.title] as? String ?? ""

return inappRating
}

// MARK: ProductStatNotifier

Expand Down
3 changes: 2 additions & 1 deletion Sources/Utilities/VisilabsConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ struct VisilabsConstants {
static let scratchToWin = "ScratchToWin"
static let productStatNotifier = "ProductStatNotifier"
static let drawer = "Drawer"

static let apprating = "MobileAppRating"


static let appBanners = "app_banners"
static let transitionAction = "transition_action"
Expand Down

0 comments on commit 9a252bf

Please sign in to comment.