lib_google

lib_huawei
This commit is contained in:
hch
2023-11-28 18:28:47 +08:00
parent 238181deca
commit 0b89ac21e8
20 changed files with 258 additions and 1475 deletions

View File

@@ -11,6 +11,9 @@ import com.google.android.gms.tasks.Task;
import com.google.firebase.FirebaseApp;
import com.google.firebase.messaging.FirebaseMessaging;
import io.rong.push.PushManager;
import io.rong.push.PushType;
public class FirebaseManage {
private Activity mActivity;
private Context mContext;
@@ -41,6 +44,8 @@ public class FirebaseManage {
token = task.getResult();
// Log and toast
Log.d("TAG", token);
PushManager.getInstance().onReceiveToken(mActivity, PushType.GOOGLE_FCM, token);
}
});
}

View File

@@ -24,6 +24,7 @@ import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -32,6 +33,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 新写Google内付工具类做简单的封装
@@ -118,13 +120,50 @@ public class GoogleBillingManage implements PurchasesUpdatedListener {
}
}
int querySize = -1;
JSONArray tokenList = new JSONArray();
JSONArray orderList = new JSONArray();
String tradeNo = "";
public JSONObject getQuerySize() {
JSONObject object = new JSONObject();
try {
object.put("querySize", querySize);
object.put("tokenList", tokenList);
object.put("orderList", orderList);
object.put("tradeNo", tradeNo);
} catch (JSONException e) {
throw new RuntimeException(e);
}
return object;
}
/**
* 消耗所有商品
*/
public void consumeAll() {
queryPurchasesAsync(new PurchasesResponseListener() {
@Override
public void onQueryPurchasesResponse(@NonNull BillingResult billingResult, @NonNull List<Purchase> list) {
querySize = list.size();
if (querySize > 0) {
tradeNo = list.get(0).getProducts().get(0);
for (Purchase purchase : list) {
tokenList.put(purchase.getPurchaseToken());
orderList.put(purchase.getOrderId());
}
consume(list);
}
}
});
}
/**
* 查询商品订单
*/
public void queryPurchasesAsync(PurchasesResponseListener responseListener) {
if (billingClient == null) return;
//内购商品交易查询
//内购商品交易查询
QueryPurchasesParams inAppPurchasesQurey = QueryPurchasesParams.newBuilder().setProductType(BillingClient.ProductType.INAPP).build();
billingClient.queryPurchasesAsync(inAppPurchasesQurey, responseListener);
}
@@ -196,6 +235,7 @@ public class GoogleBillingManage implements PurchasesUpdatedListener {
}
}
/**
* 定义接口返回支付结果
*/
@@ -211,4 +251,6 @@ public class GoogleBillingManage implements PurchasesUpdatedListener {
this.billingListener = billingListener;
return this;
}
}