Profiler - iOS
Profiler - iOS
Note - Size overhead
The size of the framework you need to download is about 12 MB. It contains compiled versions for iOS Simulators and iOS Devices.
For end users, the application download size will increase by 0.9 MB and the installed app size will increase by around 2.4 MB.
Prerequisites
To use the fraud prevention SDK (iOS), you’ll need:
- iOS 11.0+
- Xcode 12+
- Merchant Number provided by Mangopay
Setting up your Artifactory account
Once you sign the fraud prevention contract with Mangopay, your assigned solutions engineer assesses the integration of your application.
If mobile integration is needed, you will be asked to provide the email addresses of your mobile developers. Once provided, JFrog accounts will be generated for your developers and they will receive an email to set up their account.
Caution - Locked accounts
In case of multiple failed login attempts, the system will temporarily suspend that user’s account for a brief period of time during which additional login attempts will be ignored. To unlock your account, contact your assigned solutions engineer.
Getting started
Note - Sample project
There is a sample project available in Artifactory under the name nethonesdk-ios-mangopay, which may help integrate our SDK.
Installation using Swift Package Manager
Prerequisites
This integration method requires:
- Swift 5.7+
- Xcode 15+
1. Create the Dependencies directory inside your project.
2. Set it as your working directory.
3. Initialize Swift package.
4. Remove unnecessary test files.
5. Set up the repository and add your credentials to your .netrc file.
- Go to the Nethone Artifactory Repository.
- Find
nethonesdk-ios-mangopay-spmrepository. - In the top right corner, click the Set Me Up button
6. Set Artifactory as a Swift repository.
7. Add NethoneSDK dependency in the Package.swift file.
8. Resolve the package.
9. Add the Dependencies package to your Xcode project
- Open your Xcode project.
- Navigate to File > Add Package Dependencies.
- Click the Add Local button.
- Select the Dependencies directory.
Installation using CocoaPods (optional)
Note - Contact Mangopay
If you want to use the CocoaPods option, contact your assigned solutions engineer to create a CocoaPods repository for you.
Caution - CocoaPods deprecation
CocoaPods will be deprecated in later updates. We recommend you use the Swift Package Manager installation.
1. Install the latest version of CocoaPods
2. Install Artifactory CocoaPods plugin
3. Add the Artifactory repository to your application directory
4. Go to your application home directory and add the following code to your Podfile.
5. Install the pods files.
Version update
To update, you would first need to update the artifactory repository then the pods.
1. Update the artifactory repository.
2. Update the pods.
Manually
-
Download the latest version of NethoneSDK.xcframework from your Artifactory Repository. Find the
nethonesdk-ios-mangopayrepository and save it in the project folder. -
Embed frameworks into your app target. In Xcode, go to the application target General settings. On the bottom, you can find Embedded Binaries section. Add NethoneSDK.xcframework by clicking the plus + button and choose the framework from your disk.
How to update
To update, download the new version of the NethoneSDK.xcframework from Artifactory and save it in the place as the previous version, thereby overwriting it.
Initializing the SDK
Before you can use the framework, you must set the Merchant Number which is the identification number provided to you during the onboarding process.
To do so, you need to call setMerchantNumber(...) shortly after application starts.
For example in didFinishLaunchingWithOptions:
Profiling attempt
Attempt reference
The attemptReference is a unique, single-use identifier used to identify a specific profiling attempt. Your server will use this reference to query Nethone about the status of the attempt.
AttemptReference is generated by calling the beginAttempt function and is accessible by a static function named attemptReference.
Starting an attempt
Note - Concurrency of profiling attempts
Only one profiling attempt can be running at a time. You should wait for this attempt to finish before starting the next one.
To start an attempt, use the NTHNethone.beginAttempt method.
The behavioral data collection can also be turned off by setting the configuration variable config.withoutBehavioralData to true (swift) or YES (objective-c), and passing this configuration when starting the attempt.
Finalizing an attempt
Caution - Attempt and payment
You have to finalize the attempt before you process the payment.
The finalizeButtonTapped function makes sure that the necessary data has reached us. It is not recommended to terminate profiling and continue the flow until the function returns to the completion block.
Sending custom attempt data
For custom data, you can use the sendCustomAttemptData method and add the options argument to specify the type of the custom data.
The available option is DataTypeJson.
Caution - Usage errors
Calling sendCustomAttemptData on a not started or already completed attempt, or passing a data type that does not match the one provided in the options argument will return an error.
Canceling an attempt
Caution - Attempt reference usage
Once an attempt is canceled, the same attempt reference can not be reused.
Canceling an attempt immediately stops collecting and sending data without further checking whether the relevant data has been received by us.
Errors
Optional features
Note - Adding features
To use any of the optional features available, please contact your assigned solutions engineer.
Text field registration
Register a text field
The registerTextField() method will register a text field to send data from it.
The function takes a mode parameter which indicates the mode in which textField will collect data. The NTHRegisterMode enum provides constants for the data collecting options for a textField when registered.
There are 3 possible options:
- NTHRegisterMode.NoneData – No behavioral or text data will be collected.
- NTHRegisterMode.ContentFree –Only behavioral data will be collected.
- NTHRegisterMode.AllData – All behavioral and text data will be collected.
The function also takes a name parameter which describes the given textField in collected data. When left as Null, the value will be determined automatically, however it might be inaccurate.
The text fields are permanently registered, which means that data from these fields will be collected during each profiling. There is no need to register fields every time during the start of an attempt.
Customizing data collection
To collect data only from previously registered text fields instead of all UITextFields, you need to use the registered textFields.
IDFA permissions
The identifier for advertisers (IDFA) is a unique identifier assigned by Apple to a user’s iOS device. Advertisers are required to request permission to access the IDFA and track the user.
To use this feature, you will need to use the App Tracking Transparency (ATT) framework. You must also include a purpose string in the system prompt that explains why you’d like to track the user.
To access the values of the IDFA, you need:
- The user’s device on iOS 14.5+ .
- The user’s permission granted through the App Tracking Transparency prompt.
Location permissions
According to Apple’s Core Location documentation, to enable data location collection during profiling, the application should handle authorization from the user before profiling starts.
To collect the relevant data, the application needs consent for “When In Use” with the Full Accuracy option selected.
Active call detection
Note - Applicable to Chinese market
If the app is also being distributed in China, this feature is required during the Apple Review process.
The use of CallKit is prohibited in China. Due to this, Apple has introduced an additional check to make sure that the regulation is fulfilled. We made sure our solution does not use CallKit in China by using the NSLocale.regionCode function.
Apple detects the use of CallKit during the Apple Review process and makes sure the developer is aware of the regulation by rejecting the application with a message. You need to reply that your CallKit implementation is not active in China, and include a short message in the Reviewer Information section saying: “In this version and next we do not use CallKit for users in China. We detect the user’s region with NSLocale”.