Gamecenter not updating scores at the completion of submit
Hello, I am trying to pull the latest score list from the GameCenter but once it is submited, it does not comeback right away, but after 3-15 seconds delay (as in it works if I do the fetch on a delay) Here is sample of what I do doring submition/fetching, and wonder if this is just while in testflight or if there is a proper way of doing this?: [GKScore reportScores:scores withCompletionHandler:^(NSError *error) { if(!error) { ... // put break point here and wait 20 seconds, the score is returned... // if you don't break and wait here, the old (previouse) score is returned instead [leaderboardRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) { if(!error) { // do something with the score here } }]; } }]; ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Exception - completion routine is not called
Hello, I have an 'NSInternalInconsistencyException': 'Completion handler passed to -[ViewController webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:] was not called' JavaScript sends message to wkwebkit, and imediatelly after runs alert('test') (from same jscript function) The message sent to webkit will trigger some UI to come up from 3rd party pod (via presentViewController), and the return, and alert will get fired from script. The alert is NOT visible now (because the UI from pod came up), But now when I dismiss the ui, the app trhows exception above. What dismisses the alert (or why does alert's completion routine is not called if it wasn't dismissed with button)? Script part: window.webkit.messageHandlers.external.postMessage({some json data} ); alert('test'); cocoa in webkit to receive messages: - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message { //... AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [app someDelegateMethod]; //... } // now in app delegate: - (void) someDelegateMethod { //... UIViewController *uiView = [[... //this returned from a 3rd party cocoa pod) [[self topViewController] presentViewController:uiView animated:YES completion:nil]; //... } // wk alert message - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler { UIAlertController *alertController = [UIAlertController alertControllerWithTitle:webView.URL.host message:message preferredStyle:UIAlertControllerStyleAlert]; [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Close", "Close (panel/dialog/alert)") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { completionHandler(); }]]; [self presentViewController:alertController animated:YES completion:nil]; } // utils, for getting topViewController - (UIViewController*)topViewController { return [self topViewControllerWithRootViewController:[UIApplication sharedApplication].keyWindow.rootViewController]; } - (UIViewController*)topViewControllerWithRootViewController:(UIViewController*)rootViewController { if ([rootViewController isKindOfClass:[UITabBarController class]]) { UITabBarController* tabBarController = (UITabBarController*)rootViewController; return [self topViewControllerWithRootViewController:tabBarController.selectedViewController]; } else if ([rootViewController isKindOfClass:[UINavigationController class]]) { UINavigationController* navigationController = (UINavigationController*)rootViewController; return [self topViewControllerWithRootViewController:navigationController.visibleViewController]; } else if (rootViewController.presentedViewController) { UIViewController* presentedViewController = rootViewController.presentedViewController; return [self topViewControllerWithRootViewController:presentedViewController]; } else { return rootViewController; } } Thank you ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSURLProtocol
No, I mean I literally register a new protocol: xyz:// There are no typos because it is defined as a @"xyz" in the a single place in the header file, and all of the code refers to it by its define. When you go to my page at https://example.com/mypluginpage.html (for example) the Safari loads the page and creates my plugin (I know that because I can step into it :)), at which point the plugin immediately registered a new protocol 'xyz://' with NSURLProtocol, and result of registration is always YES. But it works in Safari 5.1 but NOT in Safari 5.1.10 Here are more details: On that page there is a button, it makes the plugin do some work, render an image (which I confirmed it successfully rendered and save into a file), then jscript code inserts an image into a page (same page no navigation) for example At this point I expect Safari to call method on my plugin: +(BOOL) canInitWithRequest:(NSUrlRequest): -- to ask if I handle 'xyz://' Now here is where behavior differs between Safari 5.1 and Safari 5.1.10: When the page runs in Safari 5.1 (osx 10.5) I do get calls to it for every image, script tag, style link ... basically for every link on the page, asking if I handle 'https://' to which I say NO; now when it comes time for drawing my image, it comes in the same to canInitWithRequest and asks if I handle 'xyz://' then I say YES and the rest is as expected I get the rest of the calls for canonicalization and processing the request. Now if I change to the same exact machine (osx 10.5) except that it is running Safari 5.1.10, I do the same thing, go to the web page with the plugin, it is instantiated (I can step into it) and it registers the protocol handler, and I do see all the calls coming in asking if I handle 'https://' just like before, but It NEVER comes in for 'xyz://' when its time to render my image. I have confirmed that the src of the image is correctly formatted (and NOT any different than on the machines that it does work on), but still my protocol handler never gets asked about the 'xyz' protocol (even though it returned YES when I did the register class with NSURLProtocol), and Safari acts as if 'xyz:'' has never been registered. The same behavior is consistently reproduced on other OSX version (tried on leopard and lion), the 5.1 Safari works and processes the 'xyz://' protocol, but 5.1.10 does not. > > > On Sat, Apr 11, 2015 at 8:57 PM, David Grant > wrote: > >> I’m assuming xyz:// = http:// >> >> There must something in your config designated to only respond to https:// >> ? >> >> Either that or you have both http:// and https:// written in your code >> at different points. >> >> So I suppose the first question to be asked is, do you INTEND to use http >> or https? >> >> >> On Apr 11, 2015, at 8:07 PM, danchik wrote: >> >> an npapi plugin on a web page, it registers a protocol handler >> >> On Apr 11, 2015, at 2:26 AM, Mike Abdullah wrote: >> >> >> On 11 Apr 2015, at 02:28, Dan S wrote: >> >> Is behavior of NSURLProtocol changed with Safari 5.1? >> >> I have a plugin that registeres a protocol handler xyz:// for example >> >> >> Could clarify what exactly you mean by “plugin” here? >> >> >> It succeeds and I can see all the requests to files on web pages being >> consulted with the object via >> +(BOOL) canInitWithRequest:(NSUrlRequest): >> >> With Safari 5.0 I would get consulted on all schemas (of cource it would >> only return YES for the xyz://) but with Safari 5.1.10 the only >> consultation I get (canInitWithRequest) are with the webpage schema >> (https://) and never see any calls asking about xyz:// protocol >> >> >> What can I do to get it to work in Safari 5.1.10? >> >> On PC for example, when registering custom protocol I actually have to >> specify that it is secure and ok to be invoked when running from HTTPS, I >> did not see anything like that on OSX, is that the problem and if so is >> there a fix for it? >> >> Thank you >> ___ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> Please do not post admin requests or moderator comments to the list. >> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >> >> Help/Unsubscribe/Update your Subscription: >> https://lists.apple.com/mailman/options/cocoa-dev/mabdullah%40karelia.com >> >> This email sent to mabdul...@karelia.com >> >> >> >> ___ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >
NSURLProtocol
Is behavior of NSURLProtocol changed with Safari 5.1? I have a plugin that registeres a protocol handler xyz:// for example It succeeds and I can see all the requests to files on web pages being consulted with the object via +(BOOL) canInitWithRequest:(NSUrlRequest): With Safari 5.0 I would get consulted on all schemas (of cource it would only return YES for the xyz://) but with Safari 5.1.10 the only consultation I get (canInitWithRequest) are with the webpage schema (https://) and never see any calls asking about xyz:// protocol What can I do to get it to work in Safari 5.1.10? On PC for example, when registering custom protocol I actually have to specify that it is secure and ok to be invoked when running from HTTPS, I did not see anything like that on OSX, is that the problem and if so is there a fix for it? Thank you ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSData DataWithContentsOfURL within a protocol handler
hehe, yes thank you, I was definatelly treating -startLoading it as the end all call. So, following your suggestion, to avoid calling URLProtocolDidFinishLoading from the thread, what would be preferable for calling it from main thread? performSelectorOnMainthread or listening to threadWillTerninate notification? or something else? and should I assume that the initial -startLoading came from the main thread or should I poll for which thread it came from and performSelector on that thread (in which case am I guaranteed that that particular thread is still running if it is not main)? On Thu, Sep 6, 2012 at 1:19 PM, Jens Alfke wrote: > > On Sep 6, 2012, at 11:25 AM, Dan S wrote: > > I will try to offload the server access to a different thread (though I > still need to block the protocol thread because I still have to return the > correct data for the current call). > > > No — as I said before, you should _never_ block the protocol-handler > thread. > > I think you’re misunderstanding how NSURLProtocol works. When your > -startLoading method is called, it does not have to send a response to the > client immediately. Unless you have data already available (unlikely in > your case) you should just kick off your own async request for the data, > and then immediately return. Later on as the data arrives, you can call > your client with the response and data. After everything’s done, call the > client’s URLProtocolDidFinishLoading:. (The only restriction seems to be > that you must call the client from the protocol-handler thread, i.e. the > same thread -startLoading was called on. I’ve tried to do otherwise and it > didn’t work well.) > > —Jens > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSData DataWithContentsOfURL within a protocol handler
doh! I've been treating -startLoading as a sync routine that must return a final result to the caller, and just now realized that I can return from the routine without completing the request, while the caller will be kept blocked on that request untill I respond with URLProtocolDidFinishLoading (and from a different thread if need to) so the "rewrite your code async" comment all of a sudden sounds great :) Except can I get a confirmation please that the client using the protocol handler will not reuse it untill request is completed (i.e. it wont use the same instance to make another request once I return from -startLoading, untill it gets a completion like a final redirect or URLProtocolDidFinishLoading)?? Basically I'm trying to confirm that I don't have to save the request somewhere else and keep track of it separately outside of the initial NSURLProtocol instance itself. On Thu, Sep 6, 2012 at 11:55 AM, Dan S wrote: > if you meant using the grand central dispatch, i think that only became > available in 10.6, I need to support this for 10.5 > > > On Thu, Sep 6, 2012 at 11:25 AM, Dan S wrote: > >> No, actually I've completely missed that it was answered. Thank you. >> >> Unfortunatelly, the requester is expecting a return data, error or a >> redirect. And until the api can be respeced, the sync response has to stay >> in. It isn't that it needs to load from network every request, but some >> volotile data does have to check the server to pull down the changes before >> serving the data. >> >> I will try to offload the server access to a different thread (though I >> still need to block the protocol thread because I still have to return the >> correct data for the current call). >> >> but now I'm also curiouse of what you mewant by posting a block to >> another dispatch queue ? >> >> >> On Thu, Sep 6, 2012 at 7:55 AM, Jean Suisse wrote: >> >>> Hi, >>> >>> Fritz Anderson is right. We can only agree. >>> And recently, they made following Jens Alfke's advice incredibly easy. >>> Just post a block to one of the available dispatch queues (not the one >>> running on your main thread thought) and let it run its curse. >>> >>> Jean >>> >>> On 6 sept. 2012, at 16:36, Fritz Anderson wrote: >>> >>> > From what Google tells me, you got a prompt response from Jens Alfke, >>> a very experienced Cocoa-networking programmer, explaining why what you're >>> doing shouldn't be expected to work. Are you looking for a workaround, or >>> just for somebody who will give you better news? I don't think better news >>> is in the cards. >>> >>> >>> On 29 août 2012, at 22:58, Jens Alfke wrote: >>> >>> > If you must use a synchronous API, spawn a new thread to run it on. >>> > >>> >>> >>> >>> >> > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSData DataWithContentsOfURL within a protocol handler
if you meant using the grand central dispatch, i think that only became available in 10.6, I need to support this for 10.5 On Thu, Sep 6, 2012 at 11:25 AM, Dan S wrote: > No, actually I've completely missed that it was answered. Thank you. > > Unfortunatelly, the requester is expecting a return data, error or a > redirect. And until the api can be respeced, the sync response has to stay > in. It isn't that it needs to load from network every request, but some > volotile data does have to check the server to pull down the changes before > serving the data. > > I will try to offload the server access to a different thread (though I > still need to block the protocol thread because I still have to return the > correct data for the current call). > > but now I'm also curiouse of what you mewant by posting a block to another > dispatch queue ? > > > On Thu, Sep 6, 2012 at 7:55 AM, Jean Suisse wrote: > >> Hi, >> >> Fritz Anderson is right. We can only agree. >> And recently, they made following Jens Alfke's advice incredibly easy. >> Just post a block to one of the available dispatch queues (not the one >> running on your main thread thought) and let it run its curse. >> >> Jean >> >> On 6 sept. 2012, at 16:36, Fritz Anderson wrote: >> >> > From what Google tells me, you got a prompt response from Jens Alfke, a >> very experienced Cocoa-networking programmer, explaining why what you're >> doing shouldn't be expected to work. Are you looking for a workaround, or >> just for somebody who will give you better news? I don't think better news >> is in the cards. >> >> >> On 29 août 2012, at 22:58, Jens Alfke wrote: >> >> > If you must use a synchronous API, spawn a new thread to run it on. >> > >> >> >> >> > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSData DataWithContentsOfURL within a protocol handler
No, actually I've completely missed that it was answered. Thank you. Unfortunatelly, the requester is expecting a return data, error or a redirect. And until the api can be respeced, the sync response has to stay in. It isn't that it needs to load from network every request, but some volotile data does have to check the server to pull down the changes before serving the data. I will try to offload the server access to a different thread (though I still need to block the protocol thread because I still have to return the correct data for the current call). but now I'm also curiouse of what you mewant by posting a block to another dispatch queue ? On Thu, Sep 6, 2012 at 7:55 AM, Jean Suisse wrote: > Hi, > > Fritz Anderson is right. We can only agree. > And recently, they made following Jens Alfke's advice incredibly easy. > Just post a block to one of the available dispatch queues (not the one > running on your main thread thought) and let it run its curse. > > Jean > > On 6 sept. 2012, at 16:36, Fritz Anderson wrote: > > > From what Google tells me, you got a prompt response from Jens Alfke, a > very experienced Cocoa-networking programmer, explaining why what you're > doing shouldn't be expected to work. Are you looking for a workaround, or > just for somebody who will give you better news? I don't think better news > is in the cards. > > > On 29 août 2012, at 22:58, Jens Alfke wrote: > > > If you must use a synchronous API, spawn a new thread to run it on. > > > > > > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com