首先需要去官方下載Appsflyer的UnityPackage
鏈接在這afPackage
然后導(dǎo)入
導(dǎo)入完成
引入此段代碼
using AppsFlyerSDK;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AppflysManager : MonoBehaviour
{
public static AppflysManager instance;
// Start is called before the first frame update
private void Awake()
{
instance = this;
}
void Start()
{
AppsFlyer.initSDK("your Key", "你的包名", this);
AppsFlyer.startSDK();
}
// Update is called once per frame
void Update()
{
}
public void dadian(string dingyi,string mzi,string zhi) {
Dictionary<string, string>
eventValues = new Dictionary<string, string>();
eventValues.Add("number", "1");
AppsFlyer.sendEvent(dingyi, eventValues);
}
}
然后把他掛在到一個(gè)有DontDestroyOnLoad(this)的物體上 沒有的話就自己在awake里面加一個(gè)
接下來(lái)需要引入
這個(gè)物體 Key Id和上面一樣
然后下面就是埋點(diǎn)支付的教程了
在In app 的這個(gè)方法里
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs purchaseEvent){
}
添加文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-802726.html
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs purchaseEvent){
string prodID = purchaseEvent.purchasedProduct.definition.id;
string price = purchaseEvent.purchasedProduct.metadata.localizedPrice.ToString();
string currency = purchaseEvent.purchasedProduct.metadata.isoCurrencyCode;
string receipt = purchaseEvent.purchasedProduct.receipt;
var recptToJSON = (Dictionary<string, object>)AFMiniJSON.Json.Deserialize(purchaseEvent.purchasedProduct.receipt);
var receiptPayload = (Dictionary<string, object>)AFMiniJSON.Json.Deserialize((string)recptToJSON["Payload"]);
var transactionID = purchaseEvent.purchasedProduct.transactionID;
#if UNITY_ANDROID
var purchaseData = (string)receiptPayload["json"];
var signature = (string)receiptPayload["signature"];
AppsFlyerAndroid.validateAndSendInAppPurchase(
"你的谷歌支付秘鑰",
signature,
purchaseData,
price,
currency,
null,
this);
#endif
}
至此結(jié)束文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-802726.html
到了這里,關(guān)于[Unity]關(guān)于Unity接入Appsflyer并且打點(diǎn)支付的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!