DispatchGroup issue when authenticate apple Id Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceSwift: Deadlock with DispatchGroupDispatchGroup in For LoopAny (early) experiences with auto-renewable subscriptions for iOSin-app Apple subscription…can't find information about the “Share your information” featureAuto Renewing IAP: latest_receipt fieldCheck if a non-renewable subscription was refunded by Apple?Multiple receipt count for restoreCompletedTransaction inapp purchasingiOS 6 - How to validate in-app renewable subscriptions?Completion Handler crash in AutoRenewable In-AppurchaseApple receipt_data sampleHow to know if iOS subscription is activeHow to get the correct original purchase and expires date in IAP Swift

Is there a service that would inform me whenever a new direct route is scheduled from a given airport?

What are the performance impacts of 'functional' Rust?

Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?

Single author papers against my advisor's will?

Statistical model of ligand substitution

What can I do if my MacBook isn’t charging but already ran out?

Unexpected result with right shift after bitwise negation

Autumning in love

How do I keep my slimes from escaping their pens?

What items from the Roman-age tech-level could be used to deter all creatures from entering a small area?

What do you call a plan that's an alternative plan in case your initial plan fails?

Stars Make Stars

How to stop my camera from exagerrating differences in skin colour?

New Order #5: where Fibonacci and Beatty meet at Wythoff

When communicating altitude with a '9' in it, should it be pronounced "nine hundred" or "niner hundred"?

How to say 'striped' in Latin

Estimate capacitor parameters

If I can make up priors, why can't I make up posteriors?

Stop battery usage [Ubuntu 18]

Is there a documented rationale why the House Ways and Means chairman can demand tax info?

Passing functions in C++

How can players take actions together that are impossible otherwise?

Writing Thesis: Copying from published papers

Was credit for the black hole image misattributed?



DispatchGroup issue when authenticate apple Id



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceSwift: Deadlock with DispatchGroupDispatchGroup in For LoopAny (early) experiences with auto-renewable subscriptions for iOSin-app Apple subscription…can't find information about the “Share your information” featureAuto Renewing IAP: latest_receipt fieldCheck if a non-renewable subscription was refunded by Apple?Multiple receipt count for restoreCompletedTransaction inapp purchasingiOS 6 - How to validate in-app renewable subscriptions?Completion Handler crash in AutoRenewable In-AppurchaseApple receipt_data sampleHow to know if iOS subscription is activeHow to get the correct original purchase and expires date in IAP Swift



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have one weird issue right now. I am using DispatchGroup() to verify in-app subscriptions on load. It works only if I have already authenticated with apple id.



 let dispatchGroup = DispatchGroup()

var index = 0 // <--- Just For test
for a in inAppPurchaseIds
index = index + 1
print("INDEX ENTER --> (index)")
dispatchGroup.enter() // <<---

MPInAppPurchases.verifySubscription(a) [weak self] status, data, error, expDate in
print("LOOP COUNT --> YES")

guard let me = self else
print("INDEX LEAVE ME --> (a)")

dispatchGroup.leave()
return


print("DATA ---- (String(describing: data))")

print("INDEX LEAVE --> (a)")

dispatchGroup.leave()



dispatchGroup.notify(queue: .main)
print("NOTIFY")



Function that verifies receipt



 static func verifySubscription(_ id: String, completion: purchaseHandler?) 
let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: sharedSecret)
SwiftyStoreKit.verifyReceipt(using: appleValidator) result in
switch result
case .success(let receipt):
// Verify the purchase of a Subscription
let purchaseResult = SwiftyStoreKit.verifySubscription(
ofType: .autoRenewable, // or .nonRenewing (see below)
productId: id,
inReceipt: receipt)

switch purchaseResult
case .purchased(let expiryDate, _):
print("(id) is valid until (expiryDate)")
completion?(true, "Product Purchased", nil, expiryDate)
case .expired(let expiryDate, _):
print("(id) is expired since (expiryDate)")
completion?(false, "Product Expired", nil, expiryDate)
case .notPurchased:
print("The user has never purchased (id)")
completion?(false, "Product Not Purchased", nil, nil)


case .error(let error):
print("Receipt verification failed: (error)")
completion?(false, "Receipt verification failed", error.localizedDescription, nil)





LOG



INDEX ENTER --> 1
INDEX ENTER --> 2
INDEX ENTER --> 3

LOOP COUNT --> YES
DATA ---- Optional("Product Not Purchased")
INDEX LEAVE --> kr.co.proPackage


The function returns data on completion but here I am unable to get any data from the function and only once it leaves the group. Any idea why this happens? This does happens only when I am not logged in with my apple id in my device. Once its done, it works perfectly.



Steps to reproduce the issue



Log out from my apple id > remove an app from my device > relaunch the app.










share|improve this question
























  • You need to look into SwiftyStoreKit.verifyReceipt - It seems that it doesn't always call the completion handler. Perhaps it doesn't handle concurrent operation correctly?

    – Paulw11
    Mar 22 at 8:02











  • The following is strange: Before printing LOOP COUNT --> YES, I would expect some print statement from the verifySubscription function, like (id) is valid until or Receipt verification failed or something. Could you add print statements at the beginning and at the end of that very function and post that output?

    – Andreas Oetjen
    Mar 22 at 8:06











  • @AndreasOetjen I have just removed that line from log to make it easy for Q&A.

    – EI Captain v2.0
    Mar 22 at 8:07












  • @Paulw11 Ahh maybe. But it does work after we authenticate to apple id. why so?

    – EI Captain v2.0
    Mar 22 at 8:08











  • This is the log once I authenticate with apple id. paste.ubuntu.com/p/H5SDf2ZHyR

    – EI Captain v2.0
    Mar 22 at 8:26

















0















I have one weird issue right now. I am using DispatchGroup() to verify in-app subscriptions on load. It works only if I have already authenticated with apple id.



 let dispatchGroup = DispatchGroup()

var index = 0 // <--- Just For test
for a in inAppPurchaseIds
index = index + 1
print("INDEX ENTER --> (index)")
dispatchGroup.enter() // <<---

MPInAppPurchases.verifySubscription(a) [weak self] status, data, error, expDate in
print("LOOP COUNT --> YES")

guard let me = self else
print("INDEX LEAVE ME --> (a)")

dispatchGroup.leave()
return


print("DATA ---- (String(describing: data))")

print("INDEX LEAVE --> (a)")

dispatchGroup.leave()



dispatchGroup.notify(queue: .main)
print("NOTIFY")



Function that verifies receipt



 static func verifySubscription(_ id: String, completion: purchaseHandler?) 
let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: sharedSecret)
SwiftyStoreKit.verifyReceipt(using: appleValidator) result in
switch result
case .success(let receipt):
// Verify the purchase of a Subscription
let purchaseResult = SwiftyStoreKit.verifySubscription(
ofType: .autoRenewable, // or .nonRenewing (see below)
productId: id,
inReceipt: receipt)

switch purchaseResult
case .purchased(let expiryDate, _):
print("(id) is valid until (expiryDate)")
completion?(true, "Product Purchased", nil, expiryDate)
case .expired(let expiryDate, _):
print("(id) is expired since (expiryDate)")
completion?(false, "Product Expired", nil, expiryDate)
case .notPurchased:
print("The user has never purchased (id)")
completion?(false, "Product Not Purchased", nil, nil)


case .error(let error):
print("Receipt verification failed: (error)")
completion?(false, "Receipt verification failed", error.localizedDescription, nil)





LOG



INDEX ENTER --> 1
INDEX ENTER --> 2
INDEX ENTER --> 3

LOOP COUNT --> YES
DATA ---- Optional("Product Not Purchased")
INDEX LEAVE --> kr.co.proPackage


The function returns data on completion but here I am unable to get any data from the function and only once it leaves the group. Any idea why this happens? This does happens only when I am not logged in with my apple id in my device. Once its done, it works perfectly.



Steps to reproduce the issue



Log out from my apple id > remove an app from my device > relaunch the app.










share|improve this question
























  • You need to look into SwiftyStoreKit.verifyReceipt - It seems that it doesn't always call the completion handler. Perhaps it doesn't handle concurrent operation correctly?

    – Paulw11
    Mar 22 at 8:02











  • The following is strange: Before printing LOOP COUNT --> YES, I would expect some print statement from the verifySubscription function, like (id) is valid until or Receipt verification failed or something. Could you add print statements at the beginning and at the end of that very function and post that output?

    – Andreas Oetjen
    Mar 22 at 8:06











  • @AndreasOetjen I have just removed that line from log to make it easy for Q&A.

    – EI Captain v2.0
    Mar 22 at 8:07












  • @Paulw11 Ahh maybe. But it does work after we authenticate to apple id. why so?

    – EI Captain v2.0
    Mar 22 at 8:08











  • This is the log once I authenticate with apple id. paste.ubuntu.com/p/H5SDf2ZHyR

    – EI Captain v2.0
    Mar 22 at 8:26













0












0








0








I have one weird issue right now. I am using DispatchGroup() to verify in-app subscriptions on load. It works only if I have already authenticated with apple id.



 let dispatchGroup = DispatchGroup()

var index = 0 // <--- Just For test
for a in inAppPurchaseIds
index = index + 1
print("INDEX ENTER --> (index)")
dispatchGroup.enter() // <<---

MPInAppPurchases.verifySubscription(a) [weak self] status, data, error, expDate in
print("LOOP COUNT --> YES")

guard let me = self else
print("INDEX LEAVE ME --> (a)")

dispatchGroup.leave()
return


print("DATA ---- (String(describing: data))")

print("INDEX LEAVE --> (a)")

dispatchGroup.leave()



dispatchGroup.notify(queue: .main)
print("NOTIFY")



Function that verifies receipt



 static func verifySubscription(_ id: String, completion: purchaseHandler?) 
let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: sharedSecret)
SwiftyStoreKit.verifyReceipt(using: appleValidator) result in
switch result
case .success(let receipt):
// Verify the purchase of a Subscription
let purchaseResult = SwiftyStoreKit.verifySubscription(
ofType: .autoRenewable, // or .nonRenewing (see below)
productId: id,
inReceipt: receipt)

switch purchaseResult
case .purchased(let expiryDate, _):
print("(id) is valid until (expiryDate)")
completion?(true, "Product Purchased", nil, expiryDate)
case .expired(let expiryDate, _):
print("(id) is expired since (expiryDate)")
completion?(false, "Product Expired", nil, expiryDate)
case .notPurchased:
print("The user has never purchased (id)")
completion?(false, "Product Not Purchased", nil, nil)


case .error(let error):
print("Receipt verification failed: (error)")
completion?(false, "Receipt verification failed", error.localizedDescription, nil)





LOG



INDEX ENTER --> 1
INDEX ENTER --> 2
INDEX ENTER --> 3

LOOP COUNT --> YES
DATA ---- Optional("Product Not Purchased")
INDEX LEAVE --> kr.co.proPackage


The function returns data on completion but here I am unable to get any data from the function and only once it leaves the group. Any idea why this happens? This does happens only when I am not logged in with my apple id in my device. Once its done, it works perfectly.



Steps to reproduce the issue



Log out from my apple id > remove an app from my device > relaunch the app.










share|improve this question
















I have one weird issue right now. I am using DispatchGroup() to verify in-app subscriptions on load. It works only if I have already authenticated with apple id.



 let dispatchGroup = DispatchGroup()

var index = 0 // <--- Just For test
for a in inAppPurchaseIds
index = index + 1
print("INDEX ENTER --> (index)")
dispatchGroup.enter() // <<---

MPInAppPurchases.verifySubscription(a) [weak self] status, data, error, expDate in
print("LOOP COUNT --> YES")

guard let me = self else
print("INDEX LEAVE ME --> (a)")

dispatchGroup.leave()
return


print("DATA ---- (String(describing: data))")

print("INDEX LEAVE --> (a)")

dispatchGroup.leave()



dispatchGroup.notify(queue: .main)
print("NOTIFY")



Function that verifies receipt



 static func verifySubscription(_ id: String, completion: purchaseHandler?) 
let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: sharedSecret)
SwiftyStoreKit.verifyReceipt(using: appleValidator) result in
switch result
case .success(let receipt):
// Verify the purchase of a Subscription
let purchaseResult = SwiftyStoreKit.verifySubscription(
ofType: .autoRenewable, // or .nonRenewing (see below)
productId: id,
inReceipt: receipt)

switch purchaseResult
case .purchased(let expiryDate, _):
print("(id) is valid until (expiryDate)")
completion?(true, "Product Purchased", nil, expiryDate)
case .expired(let expiryDate, _):
print("(id) is expired since (expiryDate)")
completion?(false, "Product Expired", nil, expiryDate)
case .notPurchased:
print("The user has never purchased (id)")
completion?(false, "Product Not Purchased", nil, nil)


case .error(let error):
print("Receipt verification failed: (error)")
completion?(false, "Receipt verification failed", error.localizedDescription, nil)





LOG



INDEX ENTER --> 1
INDEX ENTER --> 2
INDEX ENTER --> 3

LOOP COUNT --> YES
DATA ---- Optional("Product Not Purchased")
INDEX LEAVE --> kr.co.proPackage


The function returns data on completion but here I am unable to get any data from the function and only once it leaves the group. Any idea why this happens? This does happens only when I am not logged in with my apple id in my device. Once its done, it works perfectly.



Steps to reproduce the issue



Log out from my apple id > remove an app from my device > relaunch the app.







ios swift in-app-purchase in-app-subscription






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 7:50







EI Captain v2.0

















asked Mar 22 at 7:45









EI Captain v2.0EI Captain v2.0

18.7k96486




18.7k96486












  • You need to look into SwiftyStoreKit.verifyReceipt - It seems that it doesn't always call the completion handler. Perhaps it doesn't handle concurrent operation correctly?

    – Paulw11
    Mar 22 at 8:02











  • The following is strange: Before printing LOOP COUNT --> YES, I would expect some print statement from the verifySubscription function, like (id) is valid until or Receipt verification failed or something. Could you add print statements at the beginning and at the end of that very function and post that output?

    – Andreas Oetjen
    Mar 22 at 8:06











  • @AndreasOetjen I have just removed that line from log to make it easy for Q&A.

    – EI Captain v2.0
    Mar 22 at 8:07












  • @Paulw11 Ahh maybe. But it does work after we authenticate to apple id. why so?

    – EI Captain v2.0
    Mar 22 at 8:08











  • This is the log once I authenticate with apple id. paste.ubuntu.com/p/H5SDf2ZHyR

    – EI Captain v2.0
    Mar 22 at 8:26

















  • You need to look into SwiftyStoreKit.verifyReceipt - It seems that it doesn't always call the completion handler. Perhaps it doesn't handle concurrent operation correctly?

    – Paulw11
    Mar 22 at 8:02











  • The following is strange: Before printing LOOP COUNT --> YES, I would expect some print statement from the verifySubscription function, like (id) is valid until or Receipt verification failed or something. Could you add print statements at the beginning and at the end of that very function and post that output?

    – Andreas Oetjen
    Mar 22 at 8:06











  • @AndreasOetjen I have just removed that line from log to make it easy for Q&A.

    – EI Captain v2.0
    Mar 22 at 8:07












  • @Paulw11 Ahh maybe. But it does work after we authenticate to apple id. why so?

    – EI Captain v2.0
    Mar 22 at 8:08











  • This is the log once I authenticate with apple id. paste.ubuntu.com/p/H5SDf2ZHyR

    – EI Captain v2.0
    Mar 22 at 8:26
















You need to look into SwiftyStoreKit.verifyReceipt - It seems that it doesn't always call the completion handler. Perhaps it doesn't handle concurrent operation correctly?

– Paulw11
Mar 22 at 8:02





You need to look into SwiftyStoreKit.verifyReceipt - It seems that it doesn't always call the completion handler. Perhaps it doesn't handle concurrent operation correctly?

– Paulw11
Mar 22 at 8:02













The following is strange: Before printing LOOP COUNT --> YES, I would expect some print statement from the verifySubscription function, like (id) is valid until or Receipt verification failed or something. Could you add print statements at the beginning and at the end of that very function and post that output?

– Andreas Oetjen
Mar 22 at 8:06





The following is strange: Before printing LOOP COUNT --> YES, I would expect some print statement from the verifySubscription function, like (id) is valid until or Receipt verification failed or something. Could you add print statements at the beginning and at the end of that very function and post that output?

– Andreas Oetjen
Mar 22 at 8:06













@AndreasOetjen I have just removed that line from log to make it easy for Q&A.

– EI Captain v2.0
Mar 22 at 8:07






@AndreasOetjen I have just removed that line from log to make it easy for Q&A.

– EI Captain v2.0
Mar 22 at 8:07














@Paulw11 Ahh maybe. But it does work after we authenticate to apple id. why so?

– EI Captain v2.0
Mar 22 at 8:08





@Paulw11 Ahh maybe. But it does work after we authenticate to apple id. why so?

– EI Captain v2.0
Mar 22 at 8:08













This is the log once I authenticate with apple id. paste.ubuntu.com/p/H5SDf2ZHyR

– EI Captain v2.0
Mar 22 at 8:26





This is the log once I authenticate with apple id. paste.ubuntu.com/p/H5SDf2ZHyR

– EI Captain v2.0
Mar 22 at 8:26












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55294986%2fdispatchgroup-issue-when-authenticate-apple-id%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55294986%2fdispatchgroup-issue-when-authenticate-apple-id%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript