启用卸载衡量
总览
Complete the following sections to set up, integrate, and test iOS uninstall measurement:
- Creating a
.p12
certificate and sending it to the marketer. - Configuring the SDK for uninstall measurement.
- Testing uninstall measurement.
Creating a .p12
certificate
.p12
certificateTo enable uninstall measurement, a .p12
certificate is required.
注意
Currently,
.p8
certificates are not supported.
To create a .p12
certificate:
Step 1: Create a Certificate Signing Request (CSR)
1.1. On your Mac, open Keychain Access. Go to Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority.
1.2. Fill the form. Select Saved to disk and click Continue.
Step 2: Select App ID
2.1. Locate your Apple App ID in Apple Developer Members Center, or create one.
To create an App ID, in the Apple Developer Members Center, Go to Identifiers and click +.
2.2 Choose App IDs and click continue
2.3 Choose App and click continue
2.4. In the Register an App ID view, Under Capabilities, check Push Notifications and click Configure (Edit if it was previously configured). If the Configure/Edit button is not available, you might not have the required permissions.
Step 3: Upload CSR
3.1. Choose whether to create a Production or a Development SSL Certificate (see note) and click Create Certificate.
注意
Use a Production SSL Certificate for published apps. If your app is unpublished and is in active development, you might want to work with a Development SSL Certificate. For example, if your app isn't ready to be published yet, a Development SSL Certificate would let you test Push-related functionalities in TestFlight.
3.2. Upload the CSR you created in step 1 and click Continue.
3.3. Once the Download button appears, you are ready to download. You may need to reload the page for this to update. Download the newly created certificate.
Step 4: Create a .p12 file
4.1. Open the .cer
certificate. Opening the certificate will open Keychain Access.
4.2. In the Keychain Access, your certificate is shown under My Certificates. Select the certificate that was just added to Keychain Access.
4.3. Right-click on your certificate and select Export.
4.4. Click save. Make sure to use the Personal Information Exchange (.p12) format.
注意
If you are renewing either your Development or Production Push SSL Certificate, follow the steps listed previously. There is no need to revoke the previous certificate to make this change. Two production certificates can be in use at the same time, allowing you to continue using the old certificate while uploading the new one.
Step 5: Upload .p12
to AppsFlyer
Send the .p12
certificate to the marketer to upload to AppsFlyer.
SDK setup
请将以下代码添加到您的AppDelegate:
//add UserNotifications.framework
import UserNotifications
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// ...
application.registerForRemoteNotifications()
return true
}
// Called when the application sucessfuly registers for push notifications
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
AppsFlyerLib.shared().registerUninstall(deviceToken)
}
// AppDelegate.h
#import <AppsFlyerLib/AppsFlyerLib.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, AppsFlyerLibDelegate>
// AppDelegate.m
- #import <UserNotifications/UserNotifications.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// The userNotificationTypes below is just an example and may be changed depending on the app
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error) {
}];
[[UIApplication sharedApplication] registerForRemoteNotifications];
// if you do not use push notificaiton in your app, uncomment the following line
//application.applicationIconBadgeNumber = 0;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[[AppsFlyerLib shared] registerUninstall:deviceToken];
}
}
Enabling push notifications in background mode
如果您仅使用静默推送通知,请确保在应用的Capabilities(功能)中启用Background Modes(后台模式)的Remote Notifications(远程通知):
- In XCode, select your project.
- Select your target.
- Switch to Capabilities tab.
- Toggle Background Modes on.
- Check Remote notifications.
卸载衡量测试
请按以下步骤测试iOS卸载衡量:
- 激活应用。
- Uninstall the app. Note! You can uninstall the app immediately after installing it.
When testing uninstalls from XCode or TestFlight it is important to let our SDK know that the token is generated from a Sandbox environment. Use the following APIs:
AppsFlyerLib.shared().useUninstallSandbox = true
[AppsFlyerLib shared].setUseUninstallSandbox = true;
注意
setUseUninstallSandbox
must be called before callingregisterUninstall
.
注意事项
Uninstalls do not immediately appear in the AppsFlyer dashboard. Due to the Apple Push Notification service:
- It takes 9 days on average for iOS uninstalls to appear in reports.
- It can take more than a month for iOS uninstalls originating from sandbox environments to appear in reports.
- The date of the uninstall is the date on which the uninstall is reported. For example:
- 第1天:用户激活了您的应用
- 第2天:用户卸载了您的应用
- 第12天:Apple Push Notification Service在卸载发生的8天后上报应用卸载
- 第13天:您可以在AppsFlyer面板和原始数据报告中看到卸载数据
已更新 8 months ago