Skip to content

Commit

Permalink
Merge branch 'develop' into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuftor committed Nov 22, 2024
2 parents 928b5df + 648ccd8 commit 7b71443
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ The changelog for `SuperwallKit`. Also see the [releases](https://github.com/sup
### Enhancements

- Adds the `SuperwallOption` `shouldObservePurchases`. Set this to `true` to allow us to observe StoreKit 1 transactions you make with your app outside of Superwall. When this is enabled Superwall will not finish your external transactions. StoreKit 2 is not supported... yet.
- Adds Apple Search Ads attribution data to user attributes, which is visible on the user's page in Superwall. Attribution data will be collected if you have enabled Basic or Advanced Apple Search Ads in the Superwall dashboard settings. Advanced attribution data includes the keyword name, campaign name, bid amount, match type, and more. Otherwise, the basic attribution data will be collected, which is mostly IDs. This data will soon be added to Charts.
- Adds Apple Search Ads attribution data to user attributes, which is visible on the user's page in Superwall. Attribution data will be collected if you have enabled Basic or Advanced Apple Search Ads in the Superwall dashboard settings. Advanced attribution data includes the keyword name, campaign name, bid amount, match type, and more. Otherwise, the basic attribution data will be collected, which is mostly IDs. This data will soon be added to Charts.
- Adds `isSubscribed` to product attributes so that you can use `products.primary.isSubscribed` as a dynamic value in the paywall editor.
- Adds `device.appVersionPadded` to the device properties that you can use in audience filters.
- Adds a `notificationPermissionsDenied` `PaywallOption`, which you can set to show an alert after a user denies notification permissions.

### Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,8 @@ enum InternalSuperwallPlacement {
"storefront_id": storefrontId,
"transaction_type": type.rawValue
]
let appleSearchAttributes = Superwall.shared.userAttributes.filter { $0.key.hasPrefix("apple_search_ads_") }
eventParams += appleSearchAttributes
fallthrough
case .start,
.abandon,
Expand Down
30 changes: 30 additions & 0 deletions Sources/SuperwallKit/Config/Options/PaywallOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,36 @@ public final class PaywallOptions: NSObject, Encodable {
/// Defines the messaging of the alert presented to the user when restoring a transaction fails.
public var restoreFailed = RestoreFailed()

@objc(SWKNotificationPermissionsDenied)
@objcMembers
public final class NotificationPermissionsDenied: NSObject, Encodable {
/// The title of the alert presented to the user when notification permissions are denied. Defaults to
/// `Notification Permissions Denied`.
public var title = "Notification Permissions Denied"

/// Defines the message of the alert presented to the user when notification permissions are denied.
/// Defaults to `Please enable notification permissions from the Settings app so we can notify you when your free trial ends.`
public var message = "Please enable notification permissions from the Settings app so we can notify you when your free trial ends."

Check warning on line 62 in Sources/SuperwallKit/Config/Options/PaywallOptions.swift

View workflow job for this annotation

GitHub Actions / Package-SwiftLint

Line Length Violation: Line should be 120 characters or less; currently it has 135 characters (line_length)

/// Defines the title of the close button in the alert presented to the user when notification permissions are denied. Defaults to `Okay`.
public var closeButtonTitle = "Okay"

private enum CodingKeys: CodingKey {
case deniedTitle
case deniedMessage
case deniedCloseButtonTitle
}

public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(title, forKey: .deniedTitle)
try container.encode(message, forKey: .deniedMessage)
try container.encode(closeButtonTitle, forKey: .deniedCloseButtonTitle)
}
}
/// Defines the messaging of the alert presented to the user when notification permissions are denied.
public var notificationPermissionsDenied: NotificationPermissionsDenied?

/// Shows an alert after a purchase fails. Defaults to `true`.
///
/// Set this to `false` if you're using a `PurchaseController` and want to show
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ enum NotificationScheduler {
return
}
guard await NotificationScheduler.askForPermissionsIfNecessary(using: notificationCenter) else {
if let notificationPermissionsDenied = Superwall.shared.options.paywalls.notificationPermissionsDenied {
await withCheckedContinuation { continuation in
Task {
await Superwall.shared.paywallViewController?.presentAlert(
title: notificationPermissionsDenied.title,
message: notificationPermissionsDenied.message,
closeActionTitle: notificationPermissionsDenied.closeButtonTitle,
onClose: {

Check warning on line 48 in Sources/SuperwallKit/StoreKit/Transactions/Notifications/NotificationScheduler.swift

View workflow job for this annotation

GitHub Actions / Package-SwiftLint

Trailing Closure Violation: Trailing closure syntax should be used whenever possible (trailing_closure)
continuation.resume()
}
)
}
}
}
return
}

Expand Down

0 comments on commit 7b71443

Please sign in to comment.