-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MBX-3168: IDFA Example sample (#450)
* MBX-0000: Example - Fix CoreData warnings through first app installation * MBX-3168: Example - Add AppDelegate IDFA request sample * MBX-0000: Fix ChooseInAppMessagesDelegate shared * MBX-3168: SceneDelegate LifeCycle real example * MBX-3168: AppDelegate LifeCycle real example * MBX-3168: Revert project to default state * MBX-0000: Remove unnecessary Scene Configuration funсtion since everything is in Info.plist Application Scene Manifest If you don’t implement this method, you must provide scene-configuration data in your app’s Info.plist file. https://developer.apple.com/documentation/uikit/uiapplicationdelegate/3197905-application * MBX-3168: Remove `if #available` from IDFA Sample
- Loading branch information
Showing
8 changed files
with
123 additions
and
35 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
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
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
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
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,62 @@ | ||
// | ||
// AppDelegate_IDFA.swift | ||
// Example | ||
// | ||
// Created by Sergei Semko on 10/7/24. | ||
// Copyright © 2024 Mindbox. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import Mindbox | ||
import AppTrackingTransparency | ||
|
||
// This is only one use case. It is necessary to adapt the approach to your specific use case. | ||
|
||
@main | ||
class AppDelegate_IDFA: MindboxAppDelegate { | ||
|
||
//https://developers.mindbox.ru/docs/ios-sdk-initialization | ||
override func application( | ||
_ application: UIApplication, | ||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? | ||
) -> Bool { | ||
super.application(application, didFinishLaunchingWithOptions: launchOptions) | ||
|
||
if ATTrackingManager.trackingAuthorizationStatus != .notDetermined { | ||
initializeMindbox() | ||
} | ||
|
||
// ... | ||
return true | ||
} | ||
|
||
// If you're using scenes (iOS 13.0+), UIKit will not call this method. Use `sceneDidBecomeActive(_:)` instead. | ||
override func applicationDidBecomeActive(_ application: UIApplication) { | ||
if ATTrackingManager.trackingAuthorizationStatus == .notDetermined { | ||
DispatchQueue.main.async { | ||
ATTrackingManager.requestTrackingAuthorization { status in | ||
self.initializeMindbox() | ||
} | ||
} | ||
} | ||
} | ||
|
||
func initializeMindbox() { | ||
do { | ||
// To run the application on a physical device you need to change the endpoint | ||
// You should also change the application bundle ID in all targets, more details in the readme | ||
// You can still run the application on the simulator to see In-Apps | ||
let mindboxSdkConfig = try MBConfiguration( | ||
endpoint: "Mpush-test.ReleaseExample.IosApp", | ||
domain: "api.mindbox.ru", | ||
subscribeCustomerIfCreated: true, | ||
shouldCreateCustomer: true | ||
) | ||
Mindbox.shared.initialization(configuration: mindboxSdkConfig) | ||
} catch { | ||
print(error.localizedDescription) | ||
} | ||
} | ||
|
||
// ... | ||
} |