Neumob Accelerator User Guide: Getting Started with iOS
Introduction
The Neumob SDK for iOS provides a simple API to accelerate your mobile application traffic. Simply including and initializing the Neumob
SDK with a single line of code will enable your application access to our cloud network and accelerate your app data traffic.
Before you can speed up your application, you’ll need to go through our simple sign up process for a free Neumob account where you can register your application for a client key. If this is your first time using
Neumob, check out the portal and you can get up and running in less than 5 minutes!
Installing the iOS SDK
The minimum compatible iOS version is 7.0.
CocoaPods
If you use CocoaPods, add one of following line to your project’s podfile and run pod install or pod update.
pod ‘Neumob’, ‘0.9.5.2-beta’ // Xcode 7 - Bitcode enabled
pod ‘Neumob’, ‘0.9.5.1-beta’ // Xcode 7 - Bitcode not enabled
Manual installation (Drag and drop)
1. Download and unzip the iOS SDK. You can find a download link under your App settings.
iOS
Getting Started
iOS
2. Drag Neumob.framework into your Xcode project.
3. Link with SystemConfiguration.framework, CoreTelephony.framework, and
libresolve.9.thd (Xcode 7+) or libresolv.9.dylib (Xcode 6 and below). We use SystemConfiguration and CoreTelephony to optimize Neumob configurations for your network and to respond to any changes that may occur. We use libresolv for DNS related functions.
Initializing Neumob
Initialization is the process of modifying your application in order to communicate with Neumob. To use Neumob, you’ll have to import the
Neumob header into your AppDelegate’s implementation file. For Swift applications, place this import in your bridging-header.h file.
// AppDelegate.m (Obj-C) or bridging-header.h (Swift)
#import <Neumob/Neumob.h>
Initialize Neumob only once on the main thread at the beginning of your
AppDelegate’s application:didFinishLaunchingWithOptions: method.
// Objective C
[Neumob initialize:@“NEUMOB_CLIENT_KEY”];
// Swift
Neumob.initialize(“NEUMOB_CLIENT_KEY”);
Your client key can be retrieved on the portal by registering an application. Neumob is now integrated with your iOS application!
Verifying initialization
If you’d like to be notified once initialization is finished, you can add an optional completionHandler parameter that executes after initialize is completed. To check your Neumob’s status use the authenticated and
initialized API calls.
authenticated returns a boolean indicating whether the client key used to initialize Neumob was authenticated. Neumob cannot be initialized without the client key being authenticated.
initialized returns a boolean indicating Neumob is currently accelerating your network traffic.
Getting Started
iOS
Here’s an example of how you might verify Neumob initialization.
// Objective C
[Neumob initialize:@”NEUMOB_CLIENT_KEY” OnComplete:^{
if ([Neumob initialized]) {
...
} else if ([Neumob authenticated]) {
...
}
}];
// Swift
Neumob.initialize(“NEUMOB_CLIENT_KEY”) {
if (Neumob.authenticated()) {
...
} else if (Neumob.initialized()) {
...
}
}
At this time, we do not recommend executing your own initialization code inside the runnable block.
Disabling Neumob
If for any reason you are looking to disable Neumob, navigate to the portal to your app settings and select the combination of application versions and/or Neumob SDK versions that should be enabled. Once disabled, Neumob will not initialize on the client device.
Considerations
The Neumob iOS SDK uses and registers a custom NSURLProtocol.
If you require setting your own protocol you may consider waiting for blacklisting/whitelisting and other support in the near future.
Getting Started