在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:adjust/ios_sdk开源软件地址:https://github.com/adjust/ios_sdk开源编程语言:Objective-C 96.8%开源软件介绍:This guide is being retired. This README file will be retired shortly. The SDK documentation can now be found on our help center: SummaryThis is the iOS SDK of Adjust™. You can read more about Adjust™ at adjust.com. If your app is an app which uses web views you would like to use adjust tracking from Javascript code, please consult our iOS web views SDK guide. Read this in other languages: English, 中文, 日本語, 한국어. Table of contents
Example appsThere are example apps inside the Basic integrationWe will describe the steps to integrate the Adjust SDK into your iOS project. We are going to assume that you are using Xcode for your iOS development. Add the SDK to your projectIf you're using CocoaPods, you can add the following line to your pod 'Adjust', '~> 4.30.0' or: pod 'Adjust', :git => 'https://github.com/adjust/ios_sdk.git', :tag => 'v4.30.0' If you're using Carthage, you can add following line to your github "adjust/ios_sdk" If you're using Swift Package Manager, you can add the repository address directly in Xcode going to
You can also choose to integrate the Adjust SDK by adding it to your project as a framework. On the releases page you can find the following archives:
Since the release of iOS 8, Apple has introduced dynamic frameworks (also known as embedded frameworks). If your app is targeting iOS 8 or higher, you can use the Adjust SDK dynamic framework. Choose which framework you want to use – static or dynamic – and add it to your project. If you are having If you are having Add iOS frameworksAdjust SDK is able to get additional information in case you link additional iOS frameworks to your app. Please, add following frameworks in case you want to enable Adjust SDK features based on their presence in your app and mark them as optional:
Integrate the SDK into your appIf you added the Adjust SDK via a Pod repository, you should use one of the following import statements: #import "Adjust.h" or #import <Adjust/Adjust.h> If you added the Adjust SDK as a static/dynamic framework or via Carthage, you should use the following import statement: #import <AdjustSdk/Adjust.h> If you are are using the Adjust SDK with your tvOS app, you should use the following import statement: #import <AdjustSdkTv/Adjust.h> If you are are using the Adjust SDK with your iMessage app, you should use the following import statement: #import <AdjustSdkIm/Adjust.h> Next, we'll set up basic session tracking. Basic setupIn the Project Navigator, open the source file of your application delegate. Add the #import "Adjust.h"
// or #import <Adjust/Adjust.h>
// or #import <AdjustSdk/Adjust.h>
// or #import <AdjustSdkTv/Adjust.h>
// or #import <AdjustSdkIm/Adjust.h>
// ...
NSString *yourAppToken = @"{YourAppToken}";
NSString *environment = ADJEnvironmentSandbox;
ADJConfig *adjustConfig = [ADJConfig configWithAppToken:yourAppToken
environment:environment];
[Adjust appDidLaunch:adjustConfig]; Note: Initialising the Adjust SDK like this is Replace Depending on whether you build your app for testing or for production, you must set NSString *environment = ADJEnvironmentSandbox;
NSString *environment = ADJEnvironmentProduction; Important: This value should be set to We use this environment to distinguish between real traffic and test traffic from test devices. It is very important that you keep this value meaningful at all times! This is especially important if you are tracking revenue. iMessage specific setupAdding SDK from source: In case that you have chosen to add Adjust SDK to your iMessage app from source, please make sure that you have pre-processor macro ADJUST_IM=1 set in your iMessage project settings. Adding SDK as framework: After you have added Session tracking: If you would like to have session tracking properly working in your iMessage app, you will need to do one additional integration step. In standard iOS apps Adjust SDK is automatically subscribed to iOS system notifications which enable us to know when app entered or left foreground. In case of iMessage app, this is not the case, so we need you to add explicit calls to Add call to -(void)didBecomeActiveWithConversation:(MSConversation *)conversation {
// Called when the extension is about to move from the inactive to active state.
// This will happen when the extension is about to present UI.
// Use this method to configure the extension and restore previously stored state.
[Adjust trackSubsessionStart];
} Add call to -(void)willResignActiveWithConversation:(MSConversation *)conversation {
// Called when the extension is about to move from the active to inactive state.
// This will happen when the user dissmises the extension, changes to a different
// conversation or quits Messages.
// Use this method to release shared resources, save user data, invalidate timers,
// and store enough state information to restore your extension to its current state
// in case it is terminated later.
[Adjust trackSubsessionEnd];
} With this set, Adjust SDK will be able to successfully perform session tracking inside of your iMessage app. Note: You should be aware that your iOS app and iMessage extension you wrote for it are running in different memory spaces and they as well have different bundle identifiers. Initialising Adjust SDK with same app token in both places will result in two independent instances tracking things unaware of each other which might cause data mixture you don't want to see in your dashboard data. General advice would be to create separate app in Adjust dashboard for your iMessage app and initialise SDK inside of it with separate app token. Adjust loggingYou can increase or decrease the amount of logs that you see during testing by calling [adjustConfig setLogLevel:ADJLogLevelVerbose]; // enable all logging
[adjustConfig setLogLevel:ADJLogLevelDebug]; // enable more logging
[adjustConfig setLogLevel:ADJLogLevelInfo]; // the default
[adjustConfig setLogLevel:ADJLogLevelWarn]; // disable info logging
[adjustConfig setLogLevel:ADJLogLevelError]; // disable warnings as well
[adjustConfig setLogLevel:ADJLogLevelAssert]; // disable errors as well
[adjustConfig setLogLevel:ADJLogLevelSuppress]; // disable all logging If you don't want your app in production to display any logs coming from the Adjust SDK, then you should select #import "Adjust.h"
// or #import <Adjust/Adjust.h>
// or #import <AdjustSdk/Adjust.h>
// or #import <AdjustSdkTv/Adjust.h>
// or #import <AdjustSdkIm/Adjust.h>
// ...
NSString *yourAppToken = @"{YourAppToken}";
NSString *environment = ADJEnvironmentSandbox;
ADJConfig *adjustConfig = [ADJConfig configWithAppToken:yourAppToken
environment:environment
allowSuppressLogLevel:YES];
[Adjust appDidLaunch:adjustConfig]; Build your appBuild and run your app. If the build succeeds, you should carefully read the SDK logs in the console. After the app launches for the first time, you should see the info log Additional featuresOnce you integrate the Adjust SDK into your project, you can take advantage of the following features. AppTrackingTransparency frameworkFor each package sent, the Adjust backend receives one of the following four (4) states of consent for access to app-related data that can be used for tracking the user or the device:
After a device receives an authorization request to approve access to app-related data, which is used for user device tracking, the returned status will either be Authorized or Denied. Before a device receives an authorization request for access to app-related data, which is used for tracking the user or device, the returned status will be Not Determined. If authorization to use app tracking data is restricted, the returned status will be Restricted. The SDK has a built-in mechanism to receive an updated status after a user responds to the pop-up dialog, in case you don't want to customize your displayed dialog pop-up. To conveniently and efficiently communicate the new state of consent to the backend, Adjust SDK offers a wrapper around the app tracking authorization method described in the following chapter, App-tracking authorization wrapper. App-tracking authorisation wrapperAdjust SDK offers the possibility to use it for requesting user authorization in accessing their app-related data. Adjust SDK has a wrapper built on top of the requestTrackingAuthorizationWithCompletionHandler: method, where you can as well define the callback method to get information about a user's choice. Also, with the use of this wrapper, as soon as a user responds to the pop-up dialog, it's then communicated back using your callback method. The SDK will also inform the backend of the user's choice. The
To use this wrapper, you can call it as such: [Adjust requestTrackingAuthorizationWithCompletionHandler:^(NSUInteger status) {
switch (status) {
case 0:
// ATTrackingManagerAuthorizationStatusNotDetermined case
break;
case 1:
// ATTrackingManagerAuthorizationStatusRestricted case
break;
case 2:
// ATTrackingManagerAuthorizationStatusDenied case
break;
case 3:
// ATTrackingManagerAuthorizationStatusAuthorized case
break;
}
}]; Get current authorisation statusTo get the current app tracking authorization status you can call
Check for ATT status changeIn cases where you are not using Adjust app-tracking authorization wrapper, Adjust SDK will not be able to know immediately upon answering the dialog what is the new value of app-tracking status. In situations like this, if you would want Adjust SDK to read the new app-tracking status value and communicate it to our backend, make sure to make a call to this method: [Adjust checkForNewAttStatus]; SKAdNetwork frameworkIf you have implemented the Adjust iOS SDK v4.23.0 or above and your app is running on iOS 14, the communication with SKAdNetwork will be set on by default, although you can choose to turn it off. When set on, Adjust automatically registers for SKAdNetwork attribution when the SDK is initialized. If events are set up in the Adjust dashboard to receive conversion values, the Adjust backend sends the conversion value data to the SDK. The SDK then sets the conversion value. After Adjust receives the SKAdNetwork callback data, it is then displayed in the dashboard. In case you don't want the Adjust SDK to automatically communicate with SKAdNetwork, you can disable that by calling the following method on configuration object: [adjustConfig deactivateSKAdNetworkHandling]; Update SKAdNetwork conversion valueAs of iOS SDK v4.26.0 you can use Adjust SDK wrapper method [Adjust updateConversionValue:6]; Conversion value updated callbackYou can register callback to get notified each time when Adjust SDK updates conversion value for the user. You need to implement - (void)adjustConversionValueUpdated:(NSNumber *)conversionValue {
NSLog(@"Conversion value updated callback called!");
NSLog(@"Conversion value: %@", conversionValue);
} Event trackingYou can use adjust to track events. Lets say you want to track every tap on a particular button. You would create a new event token in your dashboard, which has an associated event token - looking something like ADJEvent *event = [ADJEvent eventWithEventToken:@"abc123"];
[Adjust trackEvent:event]; When tapping the button you should now see The event instance can be used to configure the event further before tracking it: Revenue trackingIf your users can generate revenue by tapping on advertisements or making in-app purchases you can track those revenues with events. Lets say a tap is worth one Euro cent. You could then track the revenue event like this: ADJEvent *event = [ADJEvent eventWithEventToken:@"abc123"];
[event setRevenue:0.01 currency:@"EUR"];
[Adjust trackEvent:event]; This can be combined with callback parameters of course. When you set a currency token, adjust will automatically convert the incoming revenues into a reporting revenue of your choice. Read more about currency conversion here. You can read more about revenue and event tracking in the event tracking guide. Revenue deduplicationYou can also pass in an optional transaction ID to avoid tracking duplicate revenues. The last ten transaction IDs are remembered and revenue events with duplicate transaction IDs are skipped. This is especially useful for in-app purchase tracking. See an example below. If you want to track in-app purchases, please make sure to call - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchased:
[self finishTransaction:transaction];
ADJEvent *event = [ADJEvent eventWithEventToken:...];
[event setRevenue:... currency:...];
[event setTransactionId:transaction.transactionIdentifier]; // avoid duplicates
[Adjust trackEvent:event];
break;
// more cases
}
}
} Callback parametersYou can register a callback URL for your events in your dashboard. We will send a GET request to that URL whenever the event is tracked. You can add callback parameters to that event by calling For example, suppose you have registered the URL ADJEvent *event = [ADJEvent eventWithEventToken:@"abc123"];
[event addCallbackParameter:@"key" value:@"value"];
[event addCallbackParameter:@"foo" value:@"bar"];
[Adjust trackEvent:event]; In that case we would track the event and send a request to:
It should be mentioned that we support a variety of placeholders like You can read more about using URL callbacks, including a full list of available values, in our callbacks guide. Partner parametersYou can also add parameters to be transmitted to network partners, which have been activated in your Adjust dashboard. This works similarly to the callback parameters mentioned above, but can be added by calling the ADJEvent *event = [ADJEvent eventWithEventToken:@"abc123"];
[event addPartnerParameter:@"key" value:@"value"];
[event addPartnerParameter:@"foo" value:@"bar"];
[Adjust trackEvent:event]; You can read more about special partners and these integrations in our guide to special partners. Callback identifierYou can also add custom string identifier to each event you want to track. This identifier will later be reported in event success and/or event failure callbacks to enable you to keep track on which event was successfully tracked or not. You can set this identifier by calling the ADJEvent *event = [ADJEvent eventWithEventToken:@"abc123"];
[event setCallbackId:@"Your-Custom-Id"];
[Adjust trackEvent:event]; Session parametersSome parameters are saved to be sent in every event and session of the Adjust SDK. Once you have added any of these parameters, you don't need to add them every time, since they will be saved locally. If yo |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论