- Notifications
You must be signed in to change notification settings - Fork0
hyperdevs-team/quantum-spm-mirror
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Welcome to the Quantum Metric iOS SDK Swift Package! Please review the instructions below once you've installed the package.
Add Linker FlagStep 1: Go to Build Settings in your Xcode Project.Step 2: Filter forOther Linker Flags.Step 3: Add-ObjC to the list if not already added.
If the project does not already have a Bridging Header, create one by completing the following steps. (Or, refer toApple's Bridging Header Documentation)
Under
File -> New -> File, selectHeader File, and name the file something likeMyApp-Bridging-Header.hIn your target's Build Settings, under the
Objective-C Bridging Headersettings, add the path to the new Header File you just created (this normally needs to include your app name – for example:MyApp/MyApp-Bridging-Header.h).
Once you have the bridging header settup, openMyApp-Bridging-Header.h and add#import "QMNative.h" to allow Objective-C headers to be available in Swift.
Within your App Delegate'sapplication:didFinishLaunchingWithOptions: method, initialize QMNative.
#import "QMNative.h"; //add to the top of the file [QMNative initializeWithSubscription:@"yoursubscription" uid:@"youruid"];QMNative.initialize(withSubscription: "yoursubscription", uid: "youruid")Done! You're ready to use the Quantum Metric iOS SDK.
Quantum Metric has crash reporting out of the box, however, if your app uses another service for crash reporting such as Crashlytics or Sentry, you can disable QM's internal crash reporting with the following (add this line after the initialize line):
Swift
QMNative.disableCrashReporting()
Objective-C
[QMNative disableCrashReporting];Once you have the call toinitializeWithSubscription:uid: in your app delegate, run your application and click around a bit. Within a few moments, you should see the session appear within your subscription. To find it more easily, you can search forplatform is iPhone to show sessions from iPhones (or simulators).
If you don't see your session appear, or can't find it, we can use the session callback to search for the session based on the session id. After the line that starts QM inside of your app delegate, use the session callback API to log the session information.
QMNative.gotSessionCookieCallback{(session, user)iniflet sessionCookie= session{NSLog("Quantum Metric: got session cookie: %@", sessionCookie);}};
[[QMNativesharedInstance]gotSessionCookieCallback:^(NSString *sessionCookie,NSString *userString) {NSLog(@"Quantum Metric: got session cookie:%@", sessionCookie);}];
Run your app again and search your logs forQuantum Metric. You can use the logged session cookie to search for your session, withQM Session Cookie is abc123. If you don't see theQuantum Metric log after adding the above snippet, your session didn't start because the configuration was setup in a way that excluded your session from capture, or the configuration json could not be downloaded.
Using an Event ID, which can be found in the Quantum Metric Web UI inSettings > Events, a new Event and its value can be sent through the SDK, using the following syntax:
Objective-C
[QMNativesendEventWithID:10value:@"Hello World!"];
Swift
QMNative.sendEvent(withID:10, value:"Hello World!")
Some Events signify special situations, such as conversions. These special cases can be flagged using an optional set of EventType arguments as follows:
Objective-C
[QMNativesendEventWithID:10value:@"Hello World!"flags:QMEventTypeCartValue];
Swift
QMNative.sendEvent(withID:10, value:"Hello, world", flags:QMEventTypeFlag.cartValue)
Tip: Some useful EventType options areQMEventTypeFlag.conversion,QMEventTypeFlag.cartValue andQMEventTypeFlag.encrypted
About
Resources
Uh oh!
There was an error while loading.Please reload this page.