簡體   English   中英

我的 AppDelegate 未調用 FBConnect 的 handleOpenURL 方法

[英]FBConnect's handleOpenURL Method Not Called by my AppDelegate

我已經在我的應用程序中實現了 FBConnect SDK,它在模擬器上運行良好。 然后我適當地修改了我的 app's.plist 文件,並在我的 AppDelegate 中添加了必要的方法,以便在設備上安裝 Facebook 時:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
NSLog(@"handleOpenURL Method was called and sent the following:");
NSString *urlString = [NSString stringWithContentsOfURL:(NSURL *)url];     
NSLog(@"URL String: %@", urlString);
return [[flipsideViewController facebook] handleOpenURL:url];
}

從上面的 NSLogs 和我的應用程序在通過 Facebook 授權訪問后返回到前台的觀察,我推斷 FB 應用程序正在適當地將控制權移交給我的應用程序。 不幸的是,Facebook.m 的“handleOpenURL:url”方法實際上並沒有按照我在 AppDelegate 中的請求被調用(即,以下 NSLog 均未顯示)。

- (BOOL)handleOpenURL:(NSURL *)url {
// If the URL's structure doesn't match the structure used for Facebook authorization, abort.
NSLog(@"handleOpenURL was handled by SDK. Good!");
if (![[url absoluteString] hasPrefix:[self getOwnBaseUrl]]) {
NSLog(@"handleOpenURL structure doesn't match the structure used for Facebook authorization. Aborting.");
return NO;
}
//...

As a result, my app's view controller (where I clicked my facebook button to begin with) is simply returned to the screen, and the code I placed in the 'fbDidLogin' method (used in my view controller to publish to the user's wall)永遠不會像在模擬器中那樣被調用。

我在看什么? 如果有的話,需要什么其他信息來解決這個問題? 任何幫助將不勝感激,因為我已經為此苦苦掙扎了一段時間。

重要摘要說明: 1.) 應用程序在模擬器上按需要運行。 2.) 當我從 AppDelegate 請求它時,handleOpenURL 方法沒有被調用。 3.) 我沒有收到任何錯誤/警告。 4.) 我可以在我的設備上運行 DemoApp,我注意到當“DemoAppAppDelegate”請求時,handleOpenURL 方法被適當地調用了。

提前致謝!

我最終不得不使我的 facebook object 成為 singleton (存儲在 appDelegate 中)。 不完全確定為什么這是必要的,因為我沒有在多個視圖控制器中使用 fb object。 如果您知道為什么這是必要的,請發表評論。

有關更多信息,請參閱以下鏈接:

handleOpenUrl 和 TabBar 應用程序

Facebook SDK:從多個視圖控制器調用

Cocoa 與愛:單身人士

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM