Documentation
Search
⌃K

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.3.1
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
use_frameworks!
source 'git@gitlab.appsmiles.eu:appsmiles/APMSpecs.git'
source 'https://github.com/CocoaPods/Specs.git'
pod 'APM', '~> 6.3.1'

iOS dependencies

Our SDK use the dependencies lottie-ios to work. APM.podspec :
# Dependency for APM
s.dependency 'APMServices', '5.3.1'
s.dependency 'lottie-ios'
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
import SwiftUI
import APM
@main
struct YourApp: App {
init() {
//...
//Init SDK APM
let partnerId: String = <CONFIG_PARTNER_ID>
let partnerSecret: String = <CONFIG_PARTNER_SECRET>
let appId: String = Bundle.main.bundleIdentifier
let baseUrl: String = <BASE_URL>
let apm: APM = APM.sharedInstance()
apm.initApp(partnerID: partnerId, partnerSecret: partnerSecret, appId: appId)
apm.setBaseUrl(baseUrl)
}
//...
}
You can declare multiple environments using the bundle identifier or you can specifically declare environments with the appId variable.
Swift
import SwiftUI
import APM
@main
struct YourApp: App {
init() {
//...
//Init SDK APM
let partnerId: String = <CONFIG_PARTNER_ID>
let partnerSecret: String = <CONFIG_PARTNER_SECRET>
let appId: String!
let baseUrl: String!
if(SANDBOX) {
appId = "com.your_company.your_app_sandbox"
baseUrl = "https://api-sb.appsmiles.eu/"
}
else {
appId = "com.your_company.your_app"
baseUrl = "https://api-prod1.appsmiles.eu/"
}
let apm: APM = APM.sharedInstance()
apm.initApp(partnerID: partnerId, partnerSecret: partnerSecret, appId: appId)
apm.setBaseUrl(baseUrl)
}
//...
}

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
import APM
//...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
//...
//Init SDK APM
let partnerId: String = <CONFIG_PARTNER_ID>
let partnerSecret: String = <CONFIG_PARTNER_SECRET>
let appId: String = Bundle.main.bundleIdentifier
let baseUrl: String = <BASE_URL>
let apm: APM = APM.sharedInstance()
apm.initApp(partnerID: partnerId, partnerSecret: partnerSecret, appId: appId)
apm.setBaseUrl(baseUrl)
return true
}
In YourAppDelegate.m, in the method application:didFinishLaunchingWithOptions, retrieve an instance of APM and init the SDK with your credentials environments
#import <APM/APMHeaders.h>
//...
-(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
//...
//Init SDK APM
NSString* partnerId = CONFIG_PARTNER_ID;
NSString* partnerSecret = CONFIG_PARTNER_SECRET;
NSString* appId = [[NSBundle mainBundle] bundleIdentifier];
NSString* baseUrl = BASE_URL;
APM *apm = [APM sharedInstance];
[apm initAppWithPartnerID:partnerId withPartnerSecret:partnerSecret withAppId:appId];
apm.baseUrl = baseUrl;
return YES;
}

Environments

Environment
URL
PRODUCTION
https://api-prod1.appsmiles.eu/
SANDBOX
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
import APM
...
struct GlobalView: View {
var body: some View {
VStack {
Text("Hello, world!")
.padding()
}
.onAppear(perform: {
let apm: APM = APM.sharedInstance()
apm.viewDidLoad(controller: nil)
apm.viewWillAppear(controller: nil, classID: nil)
apm.viewDidAppear(controller: nil)
})
.onDisappear(perform: {
let apm: APM = APM.sharedInstance()
apm.viewWillDisappear(controller: nil)
apm.viewDidDisappear(controller: nil)
})
}
}

Attaching to a « UIKit ViewController »

Automatically

Swift
Objective C
You can extend your GlobalViewController with APMClientViewController or APMClientNavigationController or APMClientTabBarController
import APM
...
class GlobalViewController: APMClientViewController
//OR
class GlobalViewController: APMClientNavigationController
//OR
class GlobalViewController: APMClientTabBarController
You can extend your GlobalViewController with APMClientViewController or APMClientNavigationController or APMClientTabBarController
#import <APM/APMHeaders.h>
...
@interface GlobalViewController : APMClientViewController
//OR
@interface GlobalViewController : APMClientNavigationController
//OR
@interface GlobalViewController : APMClientTabBarController

Manually

Swift
Objective C
Add the following methods in your GlobalViewController
  • viewDidLoad:controller;
  • viewWillAppear:controller;
  • viewDidAppear:controller;
  • viewWillDisappear:controller;
  • viewDidDisappear:controller;
import APM
...
override func viewDidLoad() {
super.viewDidLoad()
APMClientViewControllerUtils.viewDidLoad(self)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
APMClientViewControllerUtils.viewWillAppear(self)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
APMClientViewControllerUtils.viewDidAppear(self)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
APMClientViewControllerUtils.viewWillDisappear(self)
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
APMClientViewControllerUtils.viewDidDisappear(self)
}
Add the following methods in your GlobalViewController
  • viewDidLoad:controller;
  • viewWillAppear:controller;
  • viewDidAppear:controller;
  • viewWillDisappear:controller;
  • viewDidDisappear:controller;
#import <APM/APMHeaders.h>
...
-(void)viewDidLoad {
[super viewDidLoad];
[APMClientViewControllerUtils viewDidLoad:self];
}
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[APMClientViewControllerUtils viewWillAppear:self];
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[APMClientViewControllerUtils viewDidAppear:self];
}
-(void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[APMClientViewControllerUtils viewWillDisappear:self];
}
-(void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[APMClientViewControllerUtils viewDidDisappear:self];
}
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.