Skip to content

Commit

Permalink
Updated READMEs for sample apps and trigger
Browse files Browse the repository at this point in the history
The trigger for all sample apps is now called `campaign_trigger` to stay inline with the default trigger we give to new customers.
  • Loading branch information
yusuftor committed Feb 3, 2023
1 parent a9c3cb5 commit 6abcd40
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 44 deletions.
20 changes: 10 additions & 10 deletions Examples/SwiftUI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Usually, to integrate SuperwallKit into your app, you first need to have configu

Feature | Sample Project Location
--- | ---
🕹 Configuring SuperwallKit | [Services/SuperwallService.swift](Superwall-SwiftUI/Services/SuperwallService.swift#L23)
🕹 Configuring SuperwallKit | [Services/SuperwallService.swift](Superwall-SwiftUI/Services/SuperwallService.swift#L31)
👥 Implementing the delegate | [Services/SuperwallService.swift](Superwall-SwiftUI/Services/SuperwallService.swift#L67)
👉 Tracking an event | [TrackEventModel.swift](Superwall-SwiftUI/TrackEventModel.swift#L46)
👥 Logging In | [Services/SuperwallService.swift](Superwall-SwiftUI/Services/SuperwallService.swift#L32)
👥 Logging Out | [Services/SuperwallService.swift](Superwall-SwiftUI/Services/SuperwallService.swift#L47)
👉 Tracking an event | [TrackEventModel.swift](Superwall-SwiftUI/TrackEventModel.swift#L15)
👥 Identifying account | [Services/SuperwallService.swift](Superwall-SwiftUI/Services/SuperwallService.swift#L31)
👥 Resetting account | [Services/SuperwallService.swift](Superwall-SwiftUI/Services/SuperwallService.swift#L54)

## Requirements

Expand All @@ -33,7 +33,7 @@ Otherwise, you can download it from [https://github.com/realm/SwiftLint](https:/

Clone or download the SuperwallKit from the [project home page](https://github.com/superwall-me/Superwall-iOS). Then, open **Superwall-SwiftUI.xcodeproj** in Xcode and take a look at the code inside the [Superwall-SwiftUI](Superwall-SwiftUI) folder.

Inside the [Services](Superwall-SwiftUI/Services) folder, you'll see some helper classes. [SuperwallService.swift](Superwall-SwiftUI/Services/SuperwallService.swift) handles the setup and delegate methods of the SDK, and [StoreKitService.swift](Superwall-SwiftUI/Services/StoreKitService.swift) handles the purchasing of in-app subscriptions.
Inside the [Services](Superwall-SwiftUI/Services) folder, you'll see some helper classes. [SuperwallService.swift](Superwall-SwiftUI/Services/SuperwallService.swift) handles the setup and delegate methods of the SDK. All subscription-related logic is handled by the SDK but we have included a (commented out) example of how you might implement purchases yourself using StoreKit in [StoreKitService.swift](Superwall-SwiftUI/Services/StoreKitService.swift).

[Superwall_SwiftUI-Products.storekit](Superwall-SwiftUI/Superwall_SwiftUI-Products.storekit) is a StoreKit configuration file that is used to mimic the setup of real products on App Store Connect. This is so you can make test purchases within the sample app without having to set up App Store Connect. In a production app, you will need real products configured in App Store Connect but you can also use a StoreKit configuration file for testing purposes if you wish.

Expand All @@ -45,15 +45,15 @@ Build and run the app and you'll see the welcome screen:
<img src="https://i.imgur.com/jKkBBNW.png" alt="The welcome screen" width="220px" />
</p>

SuperwallKit is [configured](Superwall-SwiftUI/Services/SuperwallService.swift#L22) on app launch, setting an `apiKey` and `delegate`.
SuperwallKit is [configured](Superwall-SwiftUI/Services/SuperwallService.swift#L31) on app launch, setting an `apiKey` and `delegate`.

The SDK sends back events received from the paywall via the delegate methods in [SuperwallService.swift](Superwall-SwiftUI/Services/SuperwallService.swift#L67). You use these methods to make and restore purchases, react to analytical events, as well as tell the SDK whether the user has an active subscription.

## Logging In

On the welcome screen, enter your name in the **text field**. This saves to the Superwall user attributes using [Superwall.shared.setUserAttributes(_:)](Superwall-SwiftUI/Services/SuperwallService.swift#L62). You don't need to set user attributes, but it can be useful if you want to create a rule to present a paywall based on a specific attribute you've set. You can also recall user attributes on your paywall to personalise the messaging.

Tap **Log In**. This logs the user in to Superwall (with a hardcoded userId that we've set), retrieving any paywalls that have already been assigned to them. If you were to create a new account you'd use `Superwall.shared.createAccount(userId:)` instead.
Tap **Log In**. This identifies the user (with a hardcoded userId that we've set), retrieving any paywalls that have already been assigned to them.

You'll see an overview screen:

Expand All @@ -67,9 +67,9 @@ To present a paywall, you **track** an event.

On the [Superwall Dashboard](https://superwall.com/dashboard) you add this event to a Campaign and attach some presentation rules. For this app, we've already done this for you.

When an event is tracked, SuperwallKit evaluates the rules associated with it to determine whether or not to show a paywall. Note that if the delegate method [isUserSubscribed()](Superwall-SwiftUI/SuperwallService.swift#L81) returns `true`, a paywall will not show by default.
When an event is tracked, SuperwallKit evaluates the rules associated with it to determine whether or not to show a paywall.

By calling [Superwall.shared.track(event:params:paywallOverrides:paywallHandler:)](Superwall-SwiftUI/TrackEventModel.swift#L15), you present a paywall in response to the event. For this app, the event is called "MyEvent".
By calling [Superwall.shared.track(event:params:paywallOverrides:paywallHandler:)](Superwall-SwiftUI/TrackEventModel.swift#L15), you present a paywall in response to the event. For this app, the event is called `campaign_trigger`.

On screen you'll see some explanatory text and a button that tracks an event:

Expand All @@ -85,6 +85,6 @@ Tap the **Continue** button in the paywall and "purchase" a subscription. When t

## Support

For an in-depth explanation of how to use the SuperwallKit, you can [view our iOS SDK documentation](https://sdk.superwall.me/documentation/paywall/). If you'd like to view it in Xcode, select **Product ▸ Build Documentation**.
For an in-depth explanation of how to use the SuperwallKit, you can [view our iOS SDK documentation](https://sdk.superwall.me/documentation/superwallkit/). If you'd like to view it in Xcode, select **Product ▸ Build Documentation**.

For general docs that include how to use the Superwall Dashboard, visit [docs.superwall.com](https://docs.superwall.com/docs).
2 changes: 1 addition & 1 deletion Examples/SwiftUI/Superwall-SwiftUI/TrackEventModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class TrackEventModel {
// private var cancellable: AnyCancellable?

func trackEvent() {
Superwall.shared.track(event: "MyEvent") { paywallState in
Superwall.shared.track(event: "campaign_trigger") { paywallState in
switch paywallState {
case .presented(let paywallInfo):
print("paywall info is", paywallInfo)
Expand Down
2 changes: 1 addition & 1 deletion Examples/SwiftUI/Superwall-SwiftUI/TrackEventView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct TrackEventView: View {
var body: some View {
VStack(spacing: 48) {
InfoView(
text: "The button below tracks an event \"MyEvent\".\n\nThis event has been added to a campaign on the Superwall dashboard.\n\nWhen this event is tracked, the rules in the campaign are evaluated.\n\nThe rules match and cause a paywall to show."
text: "The button below tracks an event \"campaign_trigger\".\n\nThis event has been added to a campaign on the Superwall dashboard.\n\nWhen this event is tracked, the rules in the campaign are evaluated.\n\nThe rules match and cause a paywall to show."
)

Divider()
Expand Down
30 changes: 15 additions & 15 deletions Examples/UIKit+RevenueCat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ Usually, to integrate SuperwallKit into your app, you first need to have configu

Feature | Sample Project Location
--- | ---
🕹 Configuring SuperwallKit and RevenueCat | [PaywallManager.swift](Superwall-UIKit+RevenueCat/PaywallManager.swift#39)
💰 Implementing the Superwall delegate | [PaywallManager.swift](Superwall-UIKit+RevenueCat/PaywallManager.swift#L139)
😺 Implementing the RevenueCat delegate | [PaywallManager.swift](Superwall-UIKit+RevenueCat/PaywallManager.swift#L103)
👉 Presenting a paywall | [TrackEventViewController.swift](Superwall-UIKit+RevenueCat/TrackEventViewController.swift#L59)
👥 Logging In | [PaywallManager.swift](Superwall-UIKit+RevenueCat/PaywallManager.swift#L52)
👥 Logging Out | [PaywallManager.swift](Superwall-UIKit+RevenueCat/PaywallManager.swift#L73)
🕹 Configuring SuperwallKit and RevenueCat | [PaywallManager.swift](Superwall-UIKit+RevenueCat/PaywallManager.swift#37)
😺 Implementing the RevenueCat delegate | [PaywallManager.swift](Superwall-UIKit+RevenueCat/PaywallManager.swift#L144)
💰 Implementing the Superwall delegate | [PaywallManager.swift](Superwall-UIKit+RevenueCat/PaywallManager.swift#L170)
👉 Presenting a paywall | [TrackEventViewController.swift](Superwall-UIKit+RevenueCat/TrackEventViewController.swift#L60)
👥 Logging In | [PaywallManager.swift](Superwall-UIKit+RevenueCat/PaywallManager.swift#L64)
👥 Logging Out | [PaywallManager.swift](Superwall-UIKit+RevenueCat/PaywallManager.swift#L82)

## Requirements

This example app uses:

- UIKit
- RevenueCat 4.14.3
- RevenueCat 4.17.4
- Xcode 14
- iOS 16
- Swift 5.5
Expand All @@ -47,15 +47,15 @@ Build and run the app and you'll see the welcome screen:
<img src="https://user-images.githubusercontent.com/3296904/161958142-c2f195b9-bd43-4f4e-9521-87c6fe4238ec.png" alt="The welcome screen" width="220px" />
</p>

SuperwallKit and RevenueCat are both [configured](Superwall-UIKit+RevenueCat/PaywallManager.swift#L39) on app launch, setting an `apiKey` and `delegate`.
SuperwallKit and RevenueCat are both [configured](Superwall-UIKit+RevenueCat/PaywallManager.swift#L37) on app launch, setting an `apiKey` and `delegate`.

The SDK sends back events received from the paywall via the delegate methods in [PaywallManager.swift](Superwall-UIKit+RevenueCat/PaywallManager.swift#L139). You use these methods to make and restore purchases, react to analytical events, as well as tell Superwall whether the user has an active subscription.
The SDK sends back events received from the paywall via the delegate methods in [PaywallManager.swift](Superwall-UIKit+RevenueCat/PaywallManager.swift#L170). The delegate is responsible for sending back analytical events and providing a `SubscriptionController`. This is a protocol implemented by the PaywallManager that handles all subscription-related logic.

## Logging In

On the welcome screen, enter your name in the **text field**. This saves to the Superwall user attributes using [Superwall.shared.setUserAttributes(_:)](Superwall-UIKit+RevenueCat/PaywallManager.swift#L97). You don't need to set user attributes, but it can be useful if you want to create a rule to present a paywall based on a specific attribute you've set. You can also recall user attributes on your paywall to personalise the messaging.
On the welcome screen, enter your name in the **text field**. This saves to the Superwall user attributes using [Superwall.shared.setUserAttributes(_:)](Superwall-UIKit+RevenueCat/PaywallManager.swift#L102). You don't need to set user attributes, but it can be useful if you want to create a rule to present a paywall based on a specific attribute you've set. You can also recall user attributes on your paywall to personalise the messaging.

Tap **Log In**. This logs the user in to Superwall (with a hardcoded userId that we've set), retrieving any paywalls that have already been assigned to them. If you were to create a new account you'd use `Superwall.shared.createAccount(userId:)` instead.
Tap **Log In**. This identifies the user with Superwall using a hardcoded userId, retrieving any paywalls that have already been assigned to them. It also logs into revenuecat, retrieving the user's subscription status.

You'll see an overview screen:

Expand All @@ -69,9 +69,9 @@ To present a paywall, you **track** an event.

On the [Superwall Dashboard](https://superwall.com/dashboard) you add this event to a Campaign and attach some presentation rules. For this app, we've already done this for you.

When an event is tracked, SuperwallKit evaluates the rules associated with it to determine whether or not to show a paywall. Note that if the delegate method [isUserSubscribed()](Superwall-UIKit+RevenueCat/PaywallManager.swift#L163) returns `true`, a paywall will not show by default.
When an event is tracked, SuperwallKit evaluates the rules associated with it to determine whether or not to show a paywall. Note that if the `SubscriptionController` method [isUserSubscribed()](Superwall-UIKit+RevenueCat/PaywallManager.swift#L122) returns `true`, a paywall will not show by default.

By calling [Superwall.shared.track(event:params:paywallOverrides:paywallHandler:)](Superwall-UIKit+RevenueCat/TrackEventViewController.swift#L59), you present a paywall in response to the event. For this app, the event is called "MyEvent".
By calling [Superwall.shared.track(event:params:paywallOverrides:paywallHandler:)](Superwall-UIKit+RevenueCat/TrackEventViewController.swift#L60), you present a paywall in response to the event. For this app, the event is called `campaign_trigger`.

On screen you'll see some explanatory text and a button that tracks an event:

Expand All @@ -83,10 +83,10 @@ Tap the **Track Event** button and you'll see the paywall. If the event is disab

## Purchasing a subscription

Tap the **Continue** button in the paywall and "purchase" a subscription. When the paywall dismisses, try tracking an event. You'll notice the buttons no longer show the paywall. The paywalls are only presented to users who haven't got an active subscription. To cancel the active subscription for an app that's using a storekit configuration file for testing, delete and reinstall the app.
Tap the **Continue** button in the paywall and "purchase" a subscription. When the paywall dismisses, try tracking an event. You'll notice the buttons no longer show the paywall. The paywalls are only presented to users who haven't got an active subscription. To cancel the active subscription for an app that's using a storekit configuration file for testing, delete and reinstall the app. You will need to wait a few minutes until the subscription expires on RevenueCat's side before trying again.

## Support

For an in-depth explanation of how to use SuperwallKit, you can [view our iOS SDK documentation](https://sdk.superwall.me/documentation/paywall/). If you'd like to view it in Xcode, select **Product ▸ Build Documentation**.
For an in-depth explanation of how to use SuperwallKit, you can [view our iOS SDK documentation](https://sdk.superwall.me/documentation/superwallkit/). If you'd like to view it in Xcode, select **Product ▸ Build Documentation**.

For general docs that include how to use the Superwall Dashboard, visit [docs.superwall.com](https://docs.superwall.com/docs).
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ final class TrackEventViewController: UIViewController {
}

@IBAction private func trackEvent() {
Superwall.shared.track(event: "MyEvent") { paywallState in
Superwall.shared.track(event: "campaign_trigger") { paywallState in
switch paywallState {
case .presented(let paywallInfo):
print("paywall info is", paywallInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ - (void)viewWillAppear:(BOOL)animated {

- (IBAction)trackEvent:(id)sender {
__weak typeof(self) weakSelf = self;
[[Superwall sharedInstance] trackWithEvent:@"MyEvent"
[[Superwall sharedInstance] trackWithEvent:@"campaign_trigger"
params:nil
products:nil
ignoreSubscriptionStatus:NO
Expand Down
Loading

0 comments on commit 6abcd40

Please sign in to comment.