File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -2578,7 +2578,22 @@ - (void)cancelTicket {
25782578 id <GTMUIApplicationProtocol> app = [GTMSessionFetcher substituteUIApplication ];
25792579 if (app) return app;
25802580
2581- return (id <GTMUIApplicationProtocol>)[UIApplication sharedApplication ];
2581+ static Class applicationClass = nil ;
2582+ static dispatch_once_t onceToken;
2583+ dispatch_once (&onceToken, ^{
2584+ BOOL isAppExtension = [[[NSBundle mainBundle ] bundlePath ] hasSuffix: @" .appex" ];
2585+ if (!isAppExtension) {
2586+ Class cls = NSClassFromString (@" UIApplication" );
2587+ if (cls && [cls respondsToSelector: NSSelectorFromString (@" sharedApplication" )]) {
2588+ applicationClass = cls;
2589+ }
2590+ }
2591+ });
2592+
2593+ if (applicationClass) {
2594+ app = (id <GTMUIApplicationProtocol>)[applicationClass sharedApplication ];
2595+ }
2596+ return app;
25822597}
25832598#endif // GTM_BACKGROUND_TASK_FETCHING
25842599
You can’t perform that action at this time.
0 commit comments