Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
super-bryan committed Jan 23, 2024
1 parent 28c6ecd commit 833c9c4
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,15 @@ class SuperwallBridge(
}
"getUserId" -> {
// Implement logic to get the current user's id
// TODO: Add this once fixed in Android SDK
// result.success(Superwall.instance.userId)
result.success("")
val userId = Superwall.instance.userId
result.success(userId)
}
"getIsLoggedIn" -> {
// TODO: Add to Android
// val isLoggedIn = Superwall.instance.isLoggedIn
// result.success(isLoggedIn)
result.notImplemented()
val isLoggedIn = Superwall.instance.isLoggedIn
result.success(isLoggedIn)
}
"getPresentedViewController" -> {
// TODO: Since UIViewController cannot be returned directly to Dart, handle appropriately
// val viewController = Superwall.instance.presentedViewController
// result.success(viewController?.description)
result.notImplemented()
}
"getLatestPaywallInfoBridgeId" -> {
Expand Down Expand Up @@ -139,22 +134,18 @@ class SuperwallBridge(
result.success(isPaywallPresented)
}
"preloadAllPaywalls" -> {
// TODO: Add to Android
// Superwall.instance.preloadAllPaywalls()
// result.success(null)
result.notImplemented()
Superwall.instance.preloadAllPaywalls()
result.success(null)
}
"preloadPaywallsForEvents" -> {
// TODO: Add to Android
// val eventNames = call.argumentForKey<List<String>>("eventNames")?.toSet()
// eventNames?.let {
// Superwall.instance.preloadPaywalls(forEvents: it)
// }
// result.success(null)
result.notImplemented()
val eventNames = call.argumentForKey<List<String>>("eventNames")?.toSet()
eventNames?.let {
Superwall.instance.preloadPaywalls(it)
}
result.success(null)
}
"handleDeepLink" -> {
val urlString = call.argument<String>("url")
val urlString = call.argumentForKey<String>("url")
urlString?.let {
try {
val uri = Uri.parse(it)
Expand Down Expand Up @@ -222,7 +213,7 @@ class SuperwallBridge(
}
}
"registerEvent" -> {
val event = call.argument<String>("event")
val event = call.argumentForKey<String>("event")
event?.let { event ->
val params = call.argument<Map<String, Any>>("params")

Expand All @@ -246,7 +237,7 @@ class SuperwallBridge(
}

"identify" -> {
val userId = call.argument<String>("userId")
val userId = call.argumentForKey<String>("userId")
userId?.let {
val identityOptionsJson = call.argument<Map<String, Any?>>("identityOptions")
val identityOptions = identityOptionsJson?.let { JsonExtensions.identityOptionsFromJson(it) }
Expand Down
19 changes: 7 additions & 12 deletions ios/Classes/Bridges/SuperwallBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,8 @@ public class SuperwallBridge: BridgeInstance {
result(Superwall.shared.isLoggedIn)

case "getPresentedViewController":
// Implement logic to get the presented paywall view controller
// TODO: Since UIViewController cannot be returned directly to Dart, handle appropriately
if let viewController = Superwall.shared.presentedViewController {
result(viewController.description)
} else {
result(nil)
}
// TODO: Implement logic to get the presented paywall view controller
result(FlutterMethodNotImplemented)

case "getLatestPaywallInfoBridgeId":
// Implement logic to get the latest PaywallInfo object
Expand Down Expand Up @@ -91,7 +86,7 @@ public class SuperwallBridge: BridgeInstance {

case "setIsConfigured":
// Implement logic to set the configured state of Superwall
if let args = call.arguments as? [String: Any], let configured = args["configured"] as? Bool {
if let configured: Bool = call.argument(for: "configured") {
Superwall.shared.isConfigured = configured
}
result(nil)
Expand All @@ -107,23 +102,23 @@ public class SuperwallBridge: BridgeInstance {

case "preloadPaywallsForEvents":
// Implement logic to preload paywalls for specific event names
if let args = call.arguments as? [String: Any], let eventNames = args["eventNames"] as? [String] {
if let eventNames: [String] = call.argument(for: "eventNames") {
Superwall.shared.preloadPaywalls(forEvents: Set(eventNames))
}
result(nil)

case "handleDeepLink":
// Implement logic to handle deep links for paywall previews
if let args = call.arguments as? [String: Any], let urlString = args["url"] as? String, let url = URL(string: urlString) {
if let urlString: String = call.argument(for: "url"), let url = URL(string: urlString) {
let handled = Superwall.shared.handleDeepLink(url)
result(handled)
} else {
result(FlutterError(code: "INVALID_URL", message: "Invalid URL provided", details: nil))
result(call.badArgs)
}

case "togglePaywallSpinner":
// Implement logic to toggle the paywall loading spinner
if let args = call.arguments as? [String: Any], let isHidden = args["isHidden"] as? Bool {
if let isHidden: Bool = call.argument(for: "isHidden") {
Superwall.shared.togglePaywallSpinner(isHidden: isHidden)
}
result(nil)
Expand Down
1 change: 0 additions & 1 deletion lib/src/public/Experiment.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:superwallkit_flutter/src/private/BridgingCreator.dart';
import 'package:superwallkit_flutter/src/public/Variant.dart';

/// A campaign experiment that was assigned to a user.
///
Expand Down
2 changes: 0 additions & 2 deletions lib/src/public/Product.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:superwallkit_flutter/src/private/BridgingCreator.dart';

/// The product in the paywall.
class Product {
/// The type of product.
Expand Down
2 changes: 0 additions & 2 deletions lib/src/public/StoreProduct.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:superwallkit_flutter/src/public/Product.dart';

/// A wrapper around a store product.
class StoreProduct {

Expand Down
1 change: 0 additions & 1 deletion lib/src/public/SuperwallEvent.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ enum _SuperwallEventType {
paywallProductsLoadFail,
paywallProductsLoadComplete,
surveyResponse,
paywallPresentationRequest,
touchesBegan,
surveyClose,
}
14 changes: 7 additions & 7 deletions lib/src/public/TriggerResult.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class TriggerResult {
// static TriggerResult error(String error) => TriggerResult._(_TriggerResultType.error, errorDetail: error);
}

enum _TriggerResultType {
eventNotFound,
noRuleMatch,
paywall,
holdout,
error,
}
// enum _TriggerResultType {
// eventNotFound,
// noRuleMatch,
// paywall,
// holdout,
// error,
// }

0 comments on commit 833c9c4

Please sign in to comment.