-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
147 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,5 @@ App/**/*.p8 | |
*.zip | ||
*.cer | ||
App/fastlane/report.xml | ||
|
||
afdevkey.plist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,112 @@ | ||
import UIKit | ||
import Capacitor | ||
import AppsFlyerLib | ||
import AppTrackingTransparency | ||
|
||
@UIApplicationMain | ||
class AppDelegate: UIResponder, UIApplicationDelegate { | ||
class AppDelegate: UIResponder, UIApplicationDelegate, AppsFlyerLibDelegate, DeepLinkDelegate { | ||
func onConversionDataSuccess(_ conversionInfo: [AnyHashable : Any]) { | ||
print("onConversionDataSuccess: \(conversionInfo)") | ||
} | ||
|
||
func onConversionDataFail(_ error: any Error) { | ||
print("onConversionDataFail: \(error)") | ||
} | ||
|
||
|
||
var window: UIWindow? | ||
var window: UIWindow? | ||
var appFlyerReady = false | ||
|
||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | ||
// Override point for customization after application launch. | ||
return true | ||
} | ||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | ||
|
||
func applicationWillResignActive(_ application: UIApplication) { | ||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | ||
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. | ||
// Get AppsFlyer preferences from .plist file | ||
guard let propertiesPath = Bundle.main.path(forResource: "afdevkey", ofType: "plist"), | ||
let properties = NSDictionary(contentsOfFile: propertiesPath) as? [String:String] else { | ||
print("WARNING: Cannot find `afdevkey`") | ||
return true | ||
} | ||
guard let appsFlyerDevKey = properties["appsFlyerDevKey"], | ||
let appleAppID = properties["appleAppID"] else { | ||
print("WARNING: Cannot find `appsFlyerDevKey` or `appleAppID` key") | ||
return true | ||
} | ||
|
||
if appsFlyerDevKey.isEmpty || appleAppID.isEmpty { | ||
return true | ||
} | ||
|
||
self.appFlyerReady = true | ||
|
||
func applicationDidEnterBackground(_ application: UIApplication) { | ||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | ||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | ||
} | ||
AppsFlyerLib.shared().isDebug = true | ||
|
||
func applicationWillEnterForeground(_ application: UIApplication) { | ||
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. | ||
} | ||
AppsFlyerLib.shared().appsFlyerDevKey = appsFlyerDevKey | ||
AppsFlyerLib.shared().appleAppID = appleAppID | ||
|
||
func applicationDidBecomeActive(_ application: UIApplication) { | ||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | ||
} | ||
AppsFlyerLib.shared().waitForATTUserAuthorization(timeoutInterval: 60) | ||
|
||
AppsFlyerLib.shared().delegate = self | ||
AppsFlyerLib.shared().deepLinkDelegate = self | ||
|
||
print("Appflyer is ready") | ||
|
||
return true | ||
} | ||
|
||
func applicationWillTerminate(_ application: UIApplication) { | ||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | ||
} | ||
func applicationWillResignActive(_ application: UIApplication) { | ||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | ||
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. | ||
} | ||
|
||
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { | ||
// Called when the app was launched with a url. Feel free to add additional processing here, | ||
// but if you want the App API to support tracking app url opens, make sure to keep this call | ||
return ApplicationDelegateProxy.shared.application(app, open: url, options: options) | ||
} | ||
func applicationDidEnterBackground(_ application: UIApplication) { | ||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | ||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | ||
} | ||
|
||
func applicationWillEnterForeground(_ application: UIApplication) { | ||
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. | ||
} | ||
|
||
func applicationDidBecomeActive(_ application: UIApplication) { | ||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | ||
|
||
// if self.appFlyerReady { | ||
// AppsFlyerLib.shared().start() | ||
// if #available(iOS 14, *) { | ||
// ATTrackingManager.requestTrackingAuthorization { (status) in | ||
// switch status { | ||
// case .denied: | ||
// print("AuthorizationStatus is denied") | ||
// case .notDetermined: | ||
// print("AuthorizationStatus is notDetermined") | ||
// case .restricted: | ||
// print("AuthorizationStatus is restricted") | ||
// case .authorized: | ||
// print("AuthorizationStatus is authorized") | ||
// @unknown default: | ||
// fatalError("Invalid authorization status") | ||
// } | ||
// } | ||
// } | ||
// } | ||
} | ||
|
||
func applicationWillTerminate(_ application: UIApplication) { | ||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | ||
} | ||
|
||
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { | ||
// Called when the app was launched with an activity, including Universal Links. | ||
// Feel free to add additional processing here, but if you want the App API to support | ||
// tracking app url opens, make sure to keep this call | ||
return ApplicationDelegateProxy.shared.application(application, continue: userActivity, restorationHandler: restorationHandler) | ||
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { | ||
// Called when the app was launched with a url. Feel free to add additional processing here, | ||
// but if you want the App API to support tracking app url opens, make sure to keep this call | ||
if self.appFlyerReady { | ||
AppsFlyerLib.shared().handleOpen(url, options: options) | ||
} | ||
return ApplicationDelegateProxy.shared.application(app, open: url, options: options) | ||
} | ||
|
||
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { | ||
// Called when the app was launched with an activity, including Universal Links. | ||
// Feel free to add additional processing here, but if you want the App API to support | ||
// tracking app url opens, make sure to keep this call | ||
return ApplicationDelegateProxy.shared.application(application, continue: userActivity, restorationHandler: restorationHandler) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>appsFlyerDevKey</key> | ||
<string></string> | ||
<key>appleAppID</key> | ||
<string></string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters