InApp Purchase RESTORE_TRANSACTIONS, I am not able to figure the code out

后端 未结 3 1490
孤独总比滥情好
孤独总比滥情好 2021-01-17 15:14

I am adding a in app purchase in my coding, it\'s working well while purchase but gives error and application closes when I try to add Restore_Transaction code when applicat

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-17 15:46

    I found the answer to my question, thanx to anddev

    You have to check for purchases not to be null

    public static void verifyPurchase(String signedData, String signature) {
        ArrayList purchases = BillingSecurity.verifyPurchase(
                signedData, signature);
        if (purchases != null && !purchases.isEmpty()) {
            latestPurchase = purchases.get(0);
            confirmTransaction(new String[] { latestPurchase.notificationId });
            if (mCompletedHandler != null) {
                mCompletedHandler.sendEmptyMessage(0);
            } else {
                Log
                        .e(
                                TAG,
                                "verifyPurchase error. Handler not instantiated. Have you called setCompletedHandler()?");
            }
        }
    }
    

    and in Confirm_Notification u hav to check for

    if (notifyIds[0] != null)
    

提交回复
热议问题