is_in_intro_offer_period is not work anymore and the verifyReceipt endpoint is also deprecated.
https://developer.apple.com/documentation/appstorereceipts/requestbody
and,
If you need to determine whether the current subscription is within the free trial period,
you can call check if (expires_date_ms - purchase_date_ms) is less than the specified period.
https://developer.apple.com/documentation/appstoreserverapi/jwstransactiondecodedpayload
let purchase_date_ms = parseInt(latest_transcation.purchaseDate)
let expires_date_ms = parseInt(latest_transcation.expiresDate)
let duration = expires_date_ms - purchase_date_ms
var isInIntroOfferPeriod = false
// free period in your introoffer
// for example: 3 days free trial in my yearly subscription
if (duration > 0 && duration <= 3*86400000) {
isInIntroOfferPeriod = true
}
Post
Replies
Boosts
Views
Activity
any update? i found that you can use in WKURLSchemeHandler your cases.
1. add hook for webview
@implementation WKWebView (Hook)
+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Method origin = class_getClassMethod(self, @selector(handlesURLScheme:));
Method hook = class_getClassMethod(self, @selector(cdz_handlesURLScheme:));
method_exchangeImplementations(origin, hook);
});
}
+ (BOOL)cdz_handlesURLScheme:(NSString *)urlScheme {
if ([urlScheme isEqualToString:@"http"] || [urlScheme isEqualToString:@"https"]) {
return NO;
}
return [self cdz_handlesURLScheme:urlScheme];
}
@end
2. set url schemehandler
extension WKWebViewConfiguration{
class func proxyConifg() -> WKWebViewConfiguration{
let config = WKWebViewConfiguration()
let handler = HttpProxyHandler()
config.setURLSchemeHandler(handler, forURLScheme: "http")
config.setURLSchemeHandler(handler, forURLScheme: "https")
return config
}
}
3. write proxy logic in your WKURLSchemeHandler
func webView(_ webView: WKWebView, start urlSchemeTask: WKURLSchemeTask) {
let proxy_server = "YourProxyServer" // proxy server
let proxy_port = 1234 // your port
let hostKey = kCFNetworkProxiesHTTPProxy as String
let portKey = kCFNetworkProxiesHTTPPort as String
let proxyDict:[String:Any] = [kCFNetworkProxiesHTTPEnable as String: true, hostKey:proxy_server, portKey: proxy_port]
let config = URLSessionConfiguration.ephemeral
config.connectionProxyDictionary = proxyDict
let defaultSession = URLSession(configuration: config)
dataTask = defaultSession.dataTask(with: urlSchemeTask.request, completionHandler: {[weak urlSchemeTask] (data, response, error) in
/// fix crash error
guard let urlSchemeTask = urlSchemeTask else {
return
}
if let error = error {
urlSchemeTask.didFailWithError(error)
} else {
if let response = response {
urlSchemeTask.didReceive(response)
}
if let data = data {
urlSchemeTask.didReceive(data)
}
urlSchemeTask.didFinish()
}
})
dataTask?.resume()
}
:)
I have the same problem, how did you solve it.
+1 same issue
I've found that many other developers are experiencing the same problem.
Maybe there are really few games developed with Apple's GameKit, or else the engineers wouldn't have been serious about solving this problem.