com.didabu.appsflyer.unity
Version:
Didabu Unity AppsFlyer
177 lines (147 loc) • 6.91 kB
Markdown
��Ŀ¼Packages/manifest.json�ļ���������scopedRegistries��
```json
"scopedRegistries": [
{
"name": "npmjs",
"url": "https://registry.npmjs.org",
"scopes": [
"com.modesttree.zenject",
"com.mogafa",
"com.didabu"
]
}
]
```
Ȼ������dependencies������
```json
"appsflyer-unity-plugin": "https://github.com/AppsFlyerSDK/appsflyer-unity-plugin.git#upm",
"com.didabu.appsflyer.unity": "0.6.1",
```
��������ͼ��ʾ��

��Unity�༭����Edit�˵���ѡ��Project Settings����Project Settings���ڣ����������ѡ��Package Manager������һ���µ�Registry����ͼ��

����
* Name��дnpmjs
* Url��дhttps://registry.npmjs.org
* Scope(s)��д�������ݣ�com.modesttree.zenject��com.mogafa��com.didabu
Ȼ���Unity�༭����Window�˵�ѡ��Package Manager��Package Manager���ڣ�

��Package Manager�����ϣ�ѡ����ߵ�"+"����git���ӣ�

������������룺https://github.com/AppsFlyerSDK/appsflyer-unity-plugin.git#upm

���Add��ť����ʼ��װ�ٷ���Appsflyer Unity�����

��װ��ɺ���Packages:In Project���ܿ����˲����

��Package Manager�����ϣ�ѡ��PackagesΪMy Registries

Ȼ���ٴ�didabu������ѡ����Ҫ��Didabu Unity Appsflyer�汾��װ��

ʹ�����µĴ����ʼ��Appsflyer���뾡������ص���Appsflyer�ij�ʼ����
```csharp
//������using
using DidabuCloud.Unity.AppsFlyers;
```
AppsFlyer��ʼ���������������أ�
```csharp
public static Task InitAppsFlyer(this Didabu didabu, string devKey, string bundleId = null,
Action<Dictionary<string, object>> onConversionDataSuccess = null,
Action<string> onConversionDataFail = null,
Action<string> onAppOpenAttribution = null,
Action<string> onAppOpenAttributionFailure = null,
Dictionary<string, string> mediaSourceAdCreativeKeyNameMap = null)
```
���в����������£�
* didabu: Didabuʵ��
* devKey: AppsFlyer������Key
* bundleId: ��ѡ������App����(Android)��Ӧ���̵�Id(iOS)���������SDK��ʹ�ð���
* onConversionDataSuccess: ��ѡ������AppsFlyer��ʼ���ɹ��ص����μ���<https://support.appsflyer.com/hc/en-us/articles/4412870736529#onconversiondatasuccess>
* onConversionDataFail: ��ѡ������AppsFlyer��ʼ��ʧ�ܻص����μ���<https://support.appsflyer.com/hc/en-us/articles/4412870736529#onconversiondatafail>
* onAppOpenAttribution: ��ѡ������������ӻص����μ���<https://support.appsflyer.com/hc/en-us/articles/4412870736529#onappopenattribution>
* onAppOpenAttributionFailure: ��ѡ�������������ʧ�ܻص��� �μ���<https://support.appsflyer.com/hc/en-us/articles/4412870736529#onappopenattributionfailure>
* mediaSourceAdCreativeKeyNameMap: ��ѡ�����������ƽ̨�ص������а����й���ز����ƣ����ǻ�ȡ������Ƶ�Key�����ڴֹ��ƽ̨���KeyΪ"af_ad"�����߿�����Ӫ����Ա�����������ʱ��������һ��"af_ad"��key��д�ɹ���ز����ƣ����Ƕ�����Щƽ̨����Facebook��Google AdsӪ����Ա���Լ���������Key������ͨ���������ָ��ƽ̨��Ӧ��ȡ����ز����Ƶ�Key�б���
��һ�����ٲ��������أ�������������ͬ�ϣ�
```csharp
public static Task InitAppsFlyer(this Didabu didabu, string devKey, string bundleId,
Dictionary<string, string> mediaSourceAdCreativeKeyNameMap)
```
��ʼ��ʼ����
```csharp
//�뾡���������Appsflyer��ʼ��
await Didabu.Application.InitAppsFlyer("YOUR_APPSFLYER_DEV_KEY", "YOUR_PACKAGE_NAME_OR_BUNDLEID");
```
�ڳ�ʼ��ʱ���ûص������ӣ�
```csharp
await Didabu.Application.InitAppsFlyer("YOUR_APPSFLYER_DEV_KEY", "YOUR_PACKAGE_NAME_OR_BUNDLEID",
OnConversionDataSuccess,
OnConversionDataFail,
OnAppOpenAttribution,
OnAppOpenAttributionFailure
);
private void OnConversionDataSuccess(Dictionary<string, object> conversionData)
{
//�����ﴦ��conversionData
//���������ֱ��ʹ��Didabu�Ĺ�����Ϣ��
//Didabu.Application.Attribution.IsOrganic���Ƿ���Ȼ��
//Didabu.Application.Attribution.MediaSource�������Դ
//Didabu.Application.Attribution.Campaign�����
//Didabu.Application.Attribution.Creative������ز�
}
private void OnConversionDataFail(string error)
{
//�����ﴦ��������Ϣ
}
private void OnAppOpenAttribution(string message)
{
//�����ﴦ��message
}
private void OnAppOpenAttributionFailure(string error)
{
//�����ﴦ��������Ϣ
}
```
>����Ҫ���еĻص������ã�����ֻ�����ù��ĵĻص���
�ڳ�ʼ��ʱ���ù��ƽ̨��Ӧ�Ļ�ȡ����ز����Ƶ�Key�б������KeyΪ"af_ad"����Ҫ���ã�
```csharp
await Didabu.Application.InitAppsFlyer("YOUR_APPSFLYER_DEV_KEY", "YOUR_PACKAGE_NAME_OR_BUNDLEID",
new Dictionary<string, string>{{"media_source_name","creative_key_name"}});
```
����AppsFlyer�¼��ϱ��ķ���ǩ�����£�
```csharp
public static void UseAppsFlyerLogEvent(this Didabu didabu,
List<string> enabledEventNames = null,
Dictionary<string, string> eventNameMap = null,
Dictionary<string, string> eventParameterNameMap = null)
```
���в����������£�
* didabu: Didabuʵ����Didabu.Application
* enabledEventNames: ��ѡ�����������ϱ����¼������б�����ΪAppsflyer���֧��100���¼�������ͨ���˲���������Ҫ�ϱ���AppsFlyer���¼������Ϊnull����б�����ʾ�����¼���Ҫ�ϱ�
* eventNameMap: ��ѡ�������¼�����ӳ�����Didabu����ͬʱ���ɶ���¼��ϱ�ƽ̨������AppsFlyer��Firebase Analytics������Щ�¼������ڸ�ƽ̨���ض������壬����Ӧ���ڹ����¼���DidabuΪddb_purchase, Firebase AnalyticsΪin_app_purchase��AppsFlyerΪaf_purchase���������ϱ����¼�ʱ������Ϊ����ƽ̨�����ϱ������Կ���ͨ���˲��������¼�����ӳ�������������˲�����Ĭ��ֵΪ��ddb_purchaseӳ��Ϊaf_purchase��
* eventParameterNameMap����ѡ�������¼���������ӳ�����ԭ�����ϣ�����˲���δ���ã�Ĭ�Ͻ�ddbRevenueӳ��Ϊaf_revenue��
����AppsFlyer�¼��ϱ���
```csharp
Didabu.Application.UseAppsFlyerLogEvent();
```
����AppsFlyer�¼��ϱ�����ָ����Ҫ�ϱ����¼����Ƽ��¼�����ӳ�䣺
```csharp
Didabu.Application.UseAppsFlyerLogEvent(new List<string>{"ddb_purchase_","spin_", "first_open"},
new Dictionary<string, string>(){{"ddb_purchase_", "af_purchase"},
new Dictionary<string, string>(){{"ddbRevenue", "af_revenue"}});
```
> �¼����Ƶ���������
> * �ԡ�_����β�ģ����硰spin_����ʾƥ���ԡ�spin_����ʼ���¼�����ȫƥ�䡰spin���¼���������spin���͡�spin_2�������ϱ�
> * ���ԡ�_����β�ģ����硰first_open����ʾȫƥ�䣬ֻ�С�first_open�������ϱ��������"first_open_2"�Ͳ����ϱ�
ʹ�����´����ϱ��¼���
```csharp
Didabu.Application.LogEvent("test_event");
```