質問

I am using Flickr in my app. When I click on Flickr button it is redirecting to safari to login with Flickr and Authorization.

Then after successful authorization it is redirecting to my app. But after redirecting I want to call ViewWillAppear. I also set <UIApplicationDelegate> at my view. But it is not calling any of the below methods.

 -(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:YES];

    NSLog(@"@@@@@@@@@@@@@@@@@@@@@Flickr Authorized is completed");
}
- (void)UIApplicationWillEnterForeground:(UIApplication *)application
{
    NSLog(@"@@@@@@@@@@@@@@@@@@@@@Flickr Authorized is completed at foreground");
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
    /*
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     */
    NSLog(@"@@@@@@@@@@@@@@@@@@@@@Flickr Authorized is completed at become active");
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    NSLog(@"@@@@@@@@@@@@@@@@@@@@@@Flickr Authorized is completed at openURL");
}
-(void)viewWillAppear:(BOOL)animated
{
    NSLog(@"@@@@@@@@@@@@@@@@@@@@@Flickr Authorized is completed at viewWillAppear");

    [super viewWillAppear:YES];
}

But Below method is calling after redirecting from safari at AppDelegate. I have used Code from SnapAndRun flickr sample.

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    NSLog(@"@@@@@@@@@@@@@@@@@@@@@@Call Back Here@@@@@@@@@@@");

    if ([self flickrRequest].sessionInfo)
    {
        // already running some other request
        NSLog(@"Already running some other request");
    }
    else {
        NSString *token = nil;
        NSString *verifier = nil;
        BOOL result = OFExtractOAuthCallback(url, [NSURL URLWithString:SRCallbackURLBaseString], &token, &verifier);

        if (!result) {
            NSLog(@"Cannot obtain token/secret from URL: %@", [url absoluteString]);
            return NO;
        }

        [self flickrRequest].sessionInfo = kGetAccessTokenStep;
        [flickrRequest fetchOAuthAccessTokenWithRequestToken:token verifier:verifier];
        [activityIndicator startAnimating];
        //[viewController.view addSubview:progressView];
    }

    return YES;
}

I know that we can call my view controllers method here. But Is there any alternative for default delegate method to be called after redirecting at my view itself.

Any Suggestions will be appreciated. Thanks in Advance.

役に立ちましたか?

解決

You can use notificationCenter.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(someMethod:) name:@"UIApplicationDidBecomeActiveNotification" object:nil];

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top