forked from Acode-Foundation/Acode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremoveAds.js
More file actions
35 lines (31 loc) · 768 Bytes
/
removeAds.js
File metadata and controls
35 lines (31 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import purchaseListener from "handlers/purchase";
import helpers from "utils/helpers";
import { hideAd } from "./startAd.js";
/**
* Remove ads after purchase
* @returns {Promise<void>}
*/
export default function removeAds() {
return new Promise((resolve, reject) => {
iap.getProducts(["acode_pro_new"], (products) => {
const [product] = products;
iap.setPurchaseUpdatedListener(...purchaseListener(onpurchase, reject));
iap.purchase(
product.productId,
(code) => {
// ignore
},
(err) => {
alert(strings.error, err);
},
);
});
function onpurchase() {
resolve(null);
hideAd(true);
localStorage.setItem("acode_pro", "true");
window.IS_FREE_VERSION = false;
toast(strings["thank you :)"]);
}
});
}