This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BillingClient mBillingClient; | |
mBillingClient = BillingClient.newBuilder(this).setListener(new PurchasesUpdatedListener() { | |
@Override | |
public void onPurchasesUpdated(int responseCode, @Nullable List<Purchase> purchases) { | |
for(Purchase purchase: purchases) { | |
//When every a new purchase is made | |
} | |
} | |
}).build(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* To purchase an Product | |
*/ | |
final List<String> skuList = new ArrayList<>(); | |
skuList.add("product_1"); // SKU Id | |
SkuDetailsParams params = SkuDetailsParams.newBuilder() | |
.setSkusList(skuList) | |
.setType(BillingClient.SkuType.INAPP) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<String> skuList = new ArrayList<>(); | |
skuList.add("product_1"); | |
skuList.add("product_2"); | |
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder(); | |
params.setSkusList(skuList).setType(BillingClient.SkuType.INAPP); | |
mBillingClient.querySkuDetailsAsync(params.build(), | |
new SkuDetailsResponseListener() { | |
@Override | |
public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) { | |
if (responseCode == BillingClient.BillingResponse.OK |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mBillingClient.queryPurchaseHistoryAsync(SkuType.INAPP, | |
new PurchaseHistoryResponseListener() { | |
@Override | |
public void onPurchaseHistoryResponse(@BillingResponse int responseCode, | |
List<Purchase> purchasesList) { | |
if (responseCode == BillingResponse.OK | |
&& purchasesList != null) { | |
for (Purchase purchase : purchasesList) { | |
// Process the result. | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConsumeResponseListener listener = new ConsumeResponseListener() { | |
@Override | |
public void onConsumeResponse(@BillingResponse int responseCode, String outToken) { | |
if (responseCode == BillingResponse.OK) { | |
// Handle the success of the consume operation. | |
// For example, increase the number of coins inside the user's basket. | |
} | |
}; | |
mBillingClient.consumeAsync(purchaseToken, listener); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void prepareNetwork() { | |
File httpCacheDirectory = new File(getCacheDir(), "responses"); | |
int cacheSize = 10 * 1024 * 1024; // 10 MiB | |
Cache cache = new Cache(httpCacheDirectory, cacheSize); | |
OkHttpClient client = new OkHttpClient.Builder() | |
.cache(cache) | |
.addNetworkInterceptor(REWRITE_CACHE_CONTROL_INTERCEPTOR) | |
.build(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/widgets.dart'; | |
import 'package:flutter/material.dart'; | |
import 'dart:convert'; | |
/* | |
* TextView with HTML tags support By Kyle Katarn for Dart | |
* | |
* Original code by Erik Arvidsson, Mozilla Public License | |
* http://erik.eae.net/simplehtmlparser/simplehtmlparser.js | |
* and ported it on JavaScript by John Resig (ejohn.org) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:flutter/services.dart'; | |
import 'package:meta/meta.dart'; | |
enum Log { | |
DEBUG, | |
WARNING, | |
ERROR | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.ponnamkarthik.flutternativelog | |
import io.flutter.plugin.common.MethodChannel | |
import io.flutter.plugin.common.MethodChannel.MethodCallHandler | |
import io.flutter.plugin.common.MethodChannel.Result | |
import io.flutter.plugin.common.MethodCall | |
import io.flutter.plugin.common.PluginRegistry.Registrar | |
import android.util.Log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "FlutterNativeLogPlugin.h" | |
@implementation FlutterNativeLogPlugin | |
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar { | |
FlutterMethodChannel* channel = [FlutterMethodChannel | |
methodChannelWithName:@"flutter_native_log" | |
binaryMessenger:[registrar messenger]]; | |
FlutterNativeLogPlugin* instance = [[FlutterNativeLogPlugin alloc] init]; | |
[registrar addMethodCallDelegate:instance channel:channel]; | |
} |