var product_id: String?
override func viewDidLoad() {
super.viewDidLoad()
product_id = "myPurchase"
if !(UserDefaults.standard.bool(forKey: "purchased")){
if (SKPaymentQueue.canMakePayments()) {
let productID:NSSet = NSSet(object: self.product_id!);
let productsRequest:SKProductsRequest = SKProductsRequest(productIdentifiers: productID as! Set<String>);
productsRequest.delegate = self;
productsRequest.start();
print("Fetching Products");
}else{
print("Can't make purchases");
}
}
}
func productsRequest (_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
let count : Int = response.products.count
if (count>0) {
let validProduct: SKProduct = response.products[0] as SKProduct
if (validProduct.productIdentifier == self.product_id) {
buyProduct(product: validProduct);
} else {
print(validProduct.productIdentifier)
}
} else {
print("nothing")
}
}
func buyProduct(product: SKProduct){
price = localizedPriceForProduct(product)
//price2 = localizedPriceForProduct(product)
}
func localizedPriceForProduct(_ product:SKProduct) -> String {
let priceFormatter = NumberFormatter()
priceFormatter.formatterBehavior = NumberFormatter.Behavior.behavior10_4
priceFormatter.numberStyle = NumberFormatter.Style.currency
priceFormatter.locale = product.priceLocale
return priceFormatter.string(from: product.price)!
}
window.addEventListener('load', onVrViewLoad);
function onVrViewLoad() {
var vrView = new VRView.Player('#vrview', {
image: 'https://cors-anywhere.herokuapp.com/http://d305uc8ofhou21.cloudfront.net/images/vrimage/vr_kitchen.jpg',
width:'500px',
height:'300px'});
}