Setting Up Apteligent

Installing Apteligent

There are two ways you can add the Apteligent Apple SDK to your project:

  • CocoaPods (recommended)

    If you use CocoaPods, add the following line to your project’s Podfile:

    pod 'CrittercismSDK'
    

    Make sure to run pod install after making this change, and be sure to open your project from the .xcworkspace file.

  • Manual

    1. Download and unzip the Apple SDK. Copy the zip folder in your source folder.
    2. Drag the Crittercism.framework into your XCode project. The iOS framework is in the iOS folder and the tvOS framework is in the tvOS folder.
    3. Go to your XCode project: click on Build Phases and under “Link Binary with Libraries” add (‘+’) SystemConfiguration.framework and CoreData.framework.

Basic Setup

Obtain your App ID from Apteligent’s “New App Registration” page (Apteligent Quickstart).

  1. Import the Apteligent header.

For Objective-C apps, import the Apteligent header in your application delegate’s implementation file. For Swift applications, place this import in your bridging-header.h file.

#import <Crittercism/Crittercism.h>
  1. Enable Apteligent.

Call enableWithAppID in your AppDelegate’s application:didFinishLaunchingWithOptions: method.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [Crittercism enableWithAppID:@"YOUR APP ID GOES HERE"];
  // other code for your app
  return YES;
}
// Swift 2.X
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
  Crittercism.enableWithAppID("YOUR APP ID GOES HERE")
  // other code for your app
  return true
}

// Swift 3.X
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  Crittercism.enable(withAppID: "YOUR APP ID GOES HERE")
  // other code for your app
  return true
}

Register your app at the Apteligent portal to get an App ID to be used in place of "YOUR APP ID GOES HERE". See Apteligent Quickstart.

  1. Setup Automatic dSYM Uploads.

In your Xcode application target’s “Build Phases” tab, add a new Run Script.

../_images/xcode-run-script.png

Copy and paste the following code if you’re using Cocoapods:

APP_ID="REPLACE_WITH_MY_APP_ID"
API_KEY="REPLACE_WITH_MY_API_KEY"
source "${PODS_ROOT}/CrittercismSDK/dsym_upload.sh"

If you manually installed the SDK, copy and paste this code:

APP_ID="REPLACE_WITH_MY_APP_ID"
API_KEY="REPLACE_WITH_MY_API_KEY"
source "${SRCROOT}/<CRITTERCISM_DIR_NAME>/dsym_upload.sh"

When you build your Xcode application, the dSYM files for your application (and any dependent modules to which you added the Run Script) will be uploaded to Apteligent and become available for crash symbolication.

Xcode 10 Support

If you are using the new build system in Xcode 10, there is an additional requirement to support automatic dSYM upload.

Included in the zip file (if installing manually) or the cocoapod directory (if using cocoapods) is a dsym_upload.xcfilelist file. This must be added to the Input File Lists second of the Run Script phase.

Your app is now integrated with Apteligent! Additional features require adding more code to your project.

iMessage Setup

Call enableWithAppID:andConfig: in your extension’s didBecomeActiveWithConversation method.

-(void)didBecomeActiveWithConversation:(MSConversation *)conversation {
  CrittercismConfig *config = [CrittercismConfig defaultConfig];
  config.iMessageExtension = YES;

  [Crittercism enableWithAppID:@"YOUR APP ID GOES HERE" andConfig:config];
}
override func didBecomeActive(with conversation: MSConversation) {
  let config : CrittercismConfig = CrittercismConfig.default()
  config.iMessageExtension = true

  Crittercism.enable(withAppID:"YOUR APP ID GOES HERE" andConfig:config)
}

Today Extension Setup

Call enableWithAppID:andConfig: in your extension’s initWithCoder: method.

- (id)initWithCoder:(NSCoder *)aDecoder {
  self = [super initWithCoder:aDecoder];

  CrittercismConfig *config = [CrittercismConfig defaultConfig];
  config.todayExtension = YES;

  [Crittercism enableWithAppID:@"YOUR APP ID GOES HERE" andConfig:config]];
}
required init(coder aDecoder: NSCoder) {
  super.init(coder: aDecoder)

  let config : CrittercismConfig = CrittercismConfig.default()
  config.todayExtension = true

  Crittercism.enable(withAppID:"YOUR APP ID GOES HERE" andConfig:config)
}

Interoperability with other SDKs

Recommended initialization orders:

Crashlytics:

Apteligent should be initialized before Crashlytics
[Crittercism enableWithAppID:@"YOUR APP ID GOES HERE"];

// Initialize Crashlytics
// Swift 2.x

Crittercism.enableWithAppID(appID: "YOUR APP ID GOES HERE")

// Initialize Crashlytics

// Swift 3.x

Crittercism.enable(withAppID: "YOUR APP ID GOES HERE")

// Initialize Crashlytics

AppDynamics:

AppDynamics should be initialized before Apteligent
// Initialize AppDynamics

[Crittercism enableWithAppID:@"YOUR APP ID GOES HERE"];
// Swift 2.x

// Initialize AppDynamics

Crittercism.enableWithAppID(appID: "YOUR APP ID GOES HERE")

// Swift 3.x

// Initialize Crashlytics

Crittercism.enable(withAppID: "YOUR APP ID GOES HERE")

New Relic:

Apteligent should be initialized before New Relic
[Crittercism enableWithAppID:@"YOUR APP ID GOES HERE"];

// Initialize New Relic
// Swift 2.x

Crittercism.enableWithAppID(appID: "YOUR APP ID GOES HERE")

// Initialize New Relic

// Swift 3.x

Crittercism.enable(withAppID: "YOUR APP ID GOES HERE")

// Initialize New Relic