Documentation
Search…
Quickstart
Follow these steps to have a basic integration of the app's miles® SDK in your iOS application.
iOS Quickstart
Estimated time: 20 minutes
This guide will go over:
    Conditions and minimum requirements
    Installation
    📦
    Configuration
    Initialization
    Attaching
    🔗

Conditions and minimum requirements

Minimum iOS version : 10.0 Minimum Xcode version : 10

I. Installation

Last version : 6.0.2
SPM
CocaPods
In your Xcode project, select your project then the tab Swift Packages, Click on + button
Add APM swift package
https://gitlab.appsmiles.eu is a private repository, you need a login and a password Contact us to get a login and password
Select exact version for more control
Select product and target
You can see 3 packages added to your project
In your Xcode project, select your Podfile
Add pod APM
1
use_frameworks!
2
3
source 'https://gitlab.appsmiles.eu/appsmiles/APMSpecs.git'
4
source 'https://github.com/CocoaPods/Specs.git'
5
6
pod 'APM', '~> 6.0.2'
Copied!

iOS dependencies

Our SDK use the dependencies lottie-ios to work. APM.podspec :
1
# Dependency for APM
2
s.dependency 'APMServices', '5.0.2'
3
s.dependency 'lottie-ios'
Copied!
For more information about lottie-ios, click here
https://gitlab.appsmiles.eu is a private repository, you need a login and a password Set the login and password on next pod install or pod update Contact us to get a login and password
The APM SDK for iOS provides many functionalities, UI components and countless customization options at a high performance, requiring somewhat more storage space than a simpler framework would. Nonetheless, the SDK contributes only 4 MB to the final size of your application, thanks to various optimization steps that occur during the compilation and App Store submission processes

II. Initialization

You can initialize SDK APM in your :
    SwiftUI App
    UIKit App Delegate

SwiftUI App

Swift
In YourApp.swift, in the method init(), retrieve an instance of APM and init the SDK with your credentials environments
1
import SwiftUI
2
import APM
3
4
@main
5
struct YourApp: App {
6
init() {
7
//...
8
9
//Init SDK APM
10
let partnerId: String = <CONFIG_PARTNER_ID>
11
let partnerSecret: String = <CONFIG_PARTNER_SECRET>
12
let appId: String = Bundle.main.bundleIdentifier
13
let baseUrl: String = <BASE_URL>
14
15
let apm: APM = APM.sharedInstance()
16
apm.initApp(partnerID: partnerId, partnerSecret: partnerSecret, appId: appId)
17
apm.setBaseUrl(baseUrl)
18
}
19
20
//...
21
}
Copied!
You can declare multiple environments using the bundle identifier or you can specifically declare environments with the appId variable.
Swift
1
import SwiftUI
2
import APM
3
4
@main
5
struct YourApp: App {
6
init() {
7
//...
8
9
//Init SDK APM
10
let partnerId: String = <CONFIG_PARTNER_ID>
11
let partnerSecret: String = <CONFIG_PARTNER_SECRET>
12
13
let appId: String!
14
let baseUrl: String!
15
if(SANDBOX) {
16
appId = "com.your_company.your_app_sandbox"
17
baseUrl = "https://api-sb.appsmiles.eu/"
18
}
19
else {
20
appId = "com.your_company.your_app"
21
baseUrl = "https://api-prod1.appsmiles.eu/"
22
}
23
24
let apm: APM = APM.sharedInstance()
25
apm.initApp(partnerID: partnerId, partnerSecret: partnerSecret, appId: appId)
26
apm.setBaseUrl(baseUrl)
27
}
28
29
//...
30
}
Copied!

UIKit App Delegate

Swift
Objective C
In YourAppDelegate.swift, in the method application:didFinishLaunchingWithOptions, retrieve an instance of APM and init the SDK with your credentials environments
1
import APM
2
3
//...
4
5
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
6
//...
7
8
//Init SDK APM
9
let partnerId: String = <CONFIG_PARTNER_ID>
10
let partnerSecret: String = <CONFIG_PARTNER_SECRET>
11
let appId: String = Bundle.main.bundleIdentifier
12
let baseUrl: String = <BASE_URL>
13
14
let apm: APM = APM.sharedInstance()
15
apm.initApp(partnerID: partnerId, partnerSecret: partnerSecret, appId: appId)
16
apm.setBaseUrl(baseUrl)
17
18
return true
19
}
Copied!
In YourAppDelegate.m, in the method application:didFinishLaunchingWithOptions, retrieve an instance of APM and init the SDK with your credentials environments
1
#import <APM/APMHeaders.h>
2
3
//...
4
5
-(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
6
//...
7
8
//Init SDK APM
9
NSString* partnerId = CONFIG_PARTNER_ID;
10
NSString* partnerSecret = CONFIG_PARTNER_SECRET;
11
NSString* appId = [[NSBundle mainBundle] bundleIdentifier];
12
NSString* baseUrl = BASE_URL;
13
14
APM *apm = [APM sharedInstance];
15
[apm initAppWithPartnerID:partnerId withPartnerSecret:partnerSecret withAppId:appId];
16
apm.baseUrl = baseUrl;
17
18
return YES;
19
}
Copied!

Environments

Environment
URL
PRODUCTION
https://api-prod1.appsmiles.eu/
SANDOX
https://api-sb.appsmiles.eu/
We host projects on multiple servers, double check with us or your team to verify the base URL

III. Attaching

Attaching to a « SwiftUI View »

Manually

Swift
Add the following methods in your GlobalView
    onAppear
    onDisappear
1
import APM
2
3
...
4
5
struct GlobalView: View {
6
var body: some View {
7
VStack {
8
Text("Hello, world!")
9
.padding()
10
}
11
.onAppear(perform: {
12
let apm: APM = APM.sharedInstance()
13
apm.viewDidLoad(controller: nil)
14
apm.viewWillAppear(controller: nil, classID: nil)
15
apm.viewDidAppear(controller: nil)
16
})
17
.onDisappear(perform: {
18
let apm: APM = APM.sharedInstance()
19
apm.viewWillDisappear(controller: nil)
20
apm.viewDidDisappear(controller: nil)
21
})
22
}
23
}
Copied!

Attaching to a « UIKit ViewController »

Automatically

Swift
Objective C
You can extend your GlobalViewController with APMClientViewController or APMClientNavigationController or APMClientTabBarController
1
import APM
2
3
...
4
5
class GlobalViewController: APMClientViewController
6
//OR
7
class GlobalViewController: APMClientNavigationController
8
//OR
9
class GlobalViewController: APMClientTabBarController
Copied!
You can extend your GlobalViewController with APMClientViewController or APMClientNavigationController or APMClientTabBarController
1
#import <APM/APMHeaders.h>
2
3
...
4
5
@interface GlobalViewController : APMClientViewController
6
//OR
7
@interface GlobalViewController : APMClientNavigationController
8
//OR
9
@interface GlobalViewController : APMClientTabBarController
Copied!

Manually

Swift
Objective C
Add the following methods in your GlobalViewController
    viewDidLoad:controller;
    viewWillAppear:controller;
    viewDidAppear:controller;
    viewWillDisappear:controller;
    viewDidDisappear:controller;
1
import APM
2
3
...
4
5
override func viewDidLoad() {
6
super.viewDidLoad()
7
APMClientViewControllerUtils.viewDidLoad(self)
8
}
9
10
override func viewWillAppear(_ animated: Bool) {
11
super.viewWillAppear(animated)
12
APMClientViewControllerUtils.viewWillAppear(self)
13
}
14
15
override func viewDidAppear(_ animated: Bool) {
16
super.viewDidAppear(animated)
17
APMClientViewControllerUtils.viewDidAppear(self)
18
}
19
20
override func viewWillDisappear(_ animated: Bool) {
21
super.viewWillDisappear(animated)
22
APMClientViewControllerUtils.viewWillDisappear(self)
23
}
24
25
override func viewDidDisappear(_ animated: Bool) {
26
super.viewDidDisappear(animated)
27
APMClientViewControllerUtils.viewDidDisappear(self)
28
}
Copied!
Add the following methods in your GlobalViewController
    viewDidLoad:controller;
    viewWillAppear:controller;
    viewDidAppear:controller;
    viewWillDisappear:controller;
    viewDidDisappear:controller;
1
#import <APM/APMHeaders.h>
2
3
...
4
5
-(void)viewDidLoad {
6
[super viewDidLoad];
7
[APMClientViewControllerUtils viewDidLoad:self];
8
}
9
10
-(void)viewWillAppear:(BOOL)animated {
11
[super viewWillAppear:animated];
12
[APMClientViewControllerUtils viewWillAppear:self];
13
}
14
15
-(void)viewDidAppear:(BOOL)animated {
16
[super viewDidAppear:animated];
17
[APMClientViewControllerUtils viewDidAppear:self];
18
}
19
20
-(void)viewWillDisappear:(BOOL)animated {
21
[super viewWillDisappear:animated];
22
[APMClientViewControllerUtils viewWillDisappear:self];
23
}
24
25
-(void)viewDidDisappear:(BOOL)animated {
26
[super viewDidDisappear:animated];
27
[APMClientViewControllerUtils viewDidDisappear:self];
28
}
Copied!
You're done with the installation !
And the banner appear !
Head to the next section to start integrating our SDK into your app's features.
Last modified 21d ago