Tích hợp
Bạn có thể khởi tạo trình cắm bằng cách sử dụng AppsFlyerObject tạo sẵn hoặc theo cách thủ công.
- Sử dụng AppsFlyerObject.prefab
- Tích hợp thủ công
- Thu thập IDFA bằng ATTrackingManager
- Gửi đăng lại SKAN tới Appsflyer
- Khởi chạy MacOS
- Trình nghe Yêu cầu (Tùy chọn)
Sử dụng AppsFlyerObject.prefab
- Truy cập Assets > AppsFlyer và kéo AppsFlyerObject.prefab vào cảnh của bạn.
- Cập nhật các trường sau:
Cài đặt | Mô tả |
---|---|
Dev Key | Dev Key của AppsFlyer, có thể truy cập được từ bảng điều khiển AppsFlyer. |
ID ứng dụng | ID Ứng dụng iTunes của bạn. (Nếu ứng dụng của bạn không dành cho iOS, hãy để trống trường này) |
Nhận Dữ liệu Chuyển đổi | Đặt giá trị này thành true nếu ứng dụng của bạn đang sử dụng AppsFlyer để liên kết sâu. |
isDebug | Đặt giá trị này thành true để xem nhật ký gỡ lỗi. (chỉ dành cho phát triển!) |
- Cập nhật mã trong Assets > AppsFlyer > AppsFlyerObjectScript.cs với các API khác có sẵn.
Tích hợp thủ công
Tạo một đối tượng trò chơi và thêm mã init sau:
using AppsFlyerSDK;
public class AppsFlyerObjectScript : MonoBehaviour
{
void Start()
{
AppsFlyer.initSDK("devkey", "appID");
AppsFlyer.startSDK();
}
}
Lưu ý:
- Đảm bảo không gọi ra lệnh hủy đối tượng trò chơi.
- Use
DontDestroyOnLoad
để giữ lại đối tượng khi tải một cảnh mới.
Set customer user ID
Set your own unique customer user ID (CUID) and cross-reference it with the unique AppsFlyer ID.
- Appear in AppsFlyer raw data CSV reports.
- Can be used in postback APIs to cross-reference with internal IDs.
To set the CUID, use:
AppsFlyer.setCustomerUserId("someId");
Good practice! Set the CUID early in the app flow—it is only associated with events reported after its setup.
- Recorded events will be associated with the CUID.
- Related data will appear in the raw data reports for installs and events..
Associate the CUID with the install event
If it’s important for you to associate the install event with the CUID, call setCustomerUserId
before calling startSDK
.
Thu thập IDFA bằng ATTrackingManager
-
Thêm
AppTrackingTransparency
khung cho dự án xcode của bạn. -
Trong mục
Info.plist
:- Thêm một mục vào danh sách: Nhấn + bên cạnh
Information Property List
. - Cuộn xuống và chọn
Privacy - Tracking Usage Description
. - Thêm dưới dạng giá trị từ ngữ bạn muốn trình bày với người dùng khi yêu cầu quyền thu thập IDFA.
- Thêm một mục vào danh sách: Nhấn + bên cạnh
-
Gọi ra api
waitForATTUserAuthorizationWithTimeoutInterval
trướcstartSDK()
#if UNITY_IOS && !UNITY_EDITOR AppsFlyer.waitForATTUserAuthorizationWithTimeoutInterval(60); #endif
-
Yêu cầu cấp quyền theo dõi nơi bạn muốn hiển thị lời nhắc:
Bạn có thể sử dụng gói sau hoặc bất kỳ gói nào khác cho phép bạn yêu cầu cấp quyền theo dõi.using Unity.Advertisement.IosSupport; /* ... */ if (ATTrackingStatusBinding.GetAuthorizationTrackingStatus() == ATTrackingStatusBinding.AuthorizationTrackingStatus.NOT_DETERMINED) { ATTrackingStatusBinding.RequestAuthorizationTracking(); } /* ... */
Customizing the ATT consent dialog
Hộp thoại đồng ý ATT có thể được tùy chỉnh bằng cách trong dự án Xcode của bạn, sửa đổi info.plist
:
Để biết hướng dẫn chi tiết, hãy xem tài liệu của Apple.
Gửi đăng lại SKAN tới Appsflyer
Để đăng ký điểm cuối AppsFlyer, bạn cần thêm mã khóa NSAdvertisingAttributionReportEndpoint
vào info.plist của bạn và đặt giá trị thành https://appsflyer-skadnetwork.com/
.
Bạn có thể tìm thêm thông tin về cách cập nhật info.plist tại đây.
Khởi chạy MacOS
- Sử dụng bản tạo sẵn
AppsFlyerObject
- Thêm id ứng dụng MacOS của bạn
- Xây dựng cho nền tảng
PC, Mac & Linux Standelone
và chọnMacOS
làm nền tảng mục tiêu.
Trình nghe Yêu cầu (Tùy chọn)
- Đính kèm tập lệnh 'AppsFlyer.cs' vào đối tượng trò chơi bằng mã khởi tạo AppsFlyer. (AppsFlyerObject, v.v.)
- Thêm mã sau vào trước startSDK()
Ví dụ về phản hồi phiên:
void Start()
{
AppsFlyer.OnRequestResponse += AppsFlyerOnRequestResponse;
AppsFlyer.initSDK(devKey, appID, this);
AppsFlyer.startSDK();
}
void AppsFlyerOnRequestResponse(object sender, EventArgs e)
{
var args = e as AppsFlyerRequestEventArgs;
AppsFlyer.AFLog("AppsFlyerOnRequestResponse", " status code " + args.statusCode);
}
Ví dụ về phản hồi trong ứng dụng:
void Start()
{
AppsFlyer.OnInAppResponse += (sender, args) =>
{
var af_args = args as AppsFlyerRequestEventArgs;
AppsFlyer.AFLog("AppsFlyerOnRequestResponse", " status code " + af_args.statusCode);
};
AppsFlyer.initSDK(devKey, appID, this);
AppsFlyer.startSDK();
}
statusCode | errorDescription |
---|---|
200 | null |
10 | "Event timeout. Check 'minTimeBetweenSessions' param" (Hết thời gian chờ của sự kiện. Kiểm tra thông số 'minTimeBetweenSessions') |
11 | "Skipping event because 'isStopTracking' enabled" (Bỏ qua sự kiện vì 'isStopTracking' đã được bật) |
40 | Network error: Error description comes from Android (Lỗi mạng: Mô tả lỗi đến từ Android) |
41 | "No dev key" (Không có dev key) |
50 | "Status code failure" (Lỗi mã trạng thái) + mã phản hồi thực tế từ máy chủ |
Đã cập nhật 4 ngày trước