FBConnect的handleOpenURL方法未被我的AppDelegate调用 [英] FBConnect's handleOpenURL Method Not Called by my AppDelegate

查看:220
本文介绍了FBConnect的handleOpenURL方法未被我的AppDelegate调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的应用程序中实现了FBConnect SDK,并且在模拟器上工作得很好。然后我适当地修改了我的应用程序的.plist文件,并在设备上安装了Facebook时将AppDelegate添加了必要的方法:

   - (BOOL)应用程序:(UIApplication *)应用程序handleOpenURL :( NSURL *)url {
NSLog(@handleOpenURL方法被调用并发送以下内容:);
NSString * urlString = [NSString stringWithContentsOfURL:(NSURL *)url];
NSLog(@URL String:%@,urlString);
return [[flipsideViewController facebook] handleOpenURL:url];
}

从上面的NSLogs和观察我的应用程序返回到前台后授权通过Facebook访问,我推断,FB应用程序正在适当地移交给我的应用程序的控制权。不幸的是,Facebook.m的handleOpenURL:url方法实际上没有像我在AppDelegate中请求一样调用(即,不显示以下NSLogs)。

   - (BOOL)handleOpenURL:(NSURL *)url {
//如果URL的结构与用于Facebook授权的结构不匹配,则中止。
NSLog(@handleOpenURL由SDK处理好!);
if(![[url absoluteString] hasPrefix:[self getOwnBaseUrl]]){
NSLog(@handleOpenURL结构与用于Facebook授权的结构不匹配)。
return NO;
}
// ...

因此,我的应用程序的视图控制器(我点击我的Facebook按钮开始)只是返回到屏幕,我放在'fbDidLogin'方法(在我的视图控制器中用于发布到用户的墙上)的代码从来没有被调用模拟器。



我俯视什么?需要什么其他信息来解决这个问题?任何帮助将非常感激,因为我一直在努力一段时间。



重要摘要注:
1.)应用程序在模拟器上运行。
2.)handleOpenURL当我从AppDelegate请求它时,不调用方法。
3.)我没有收到任何错误/警告。
4.)我可以在我的设备上运行DemoApp,我注意到handleOpenURL方法被DemoAppAppDelegate请求时被适当地调用。



谢谢

解决方案

我最终不得不让我的Facebook对象成为一个单身(存储在appDelegate中)。不完全确定为什么这是必要的,因为我没有在多个viewController中使用fb对象。请注意,如果您知道为什么这是必要的。



有关详细信息,请参阅以下链接:



handleOpenUrl和TabBar应用程序



<一个href =https://stackoverflow.com/questions/5340375/facebook-ios-sdk-iphone-call-from-multiple-viewcontroller> Facebook SDK:来自多个视图控件的呼叫



可爱与爱:单身人士


I have implemented the FBConnect SDK into my app, and it works perfectly on the simulator. I then modified my app's .plist file appropriately, and added the necessary method to my AppDelegate for when Facebook is installed on the device:

- (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];
}

From the above NSLogs and the observation that my application is returned to the foreground after authorizing access via Facebook, I infer that the FB App is handing off control to my application appropriately. Unfortunately, Facebook.m's "handleOpenURL:url" method does not actually get called as I request in my AppDelegate (i.e. neither of the below NSLogs are displayed).

- (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) never gets called as it did in the simulator.

What am I overlooking? What, if any, other information is needed to solve this problem? Any help would be very much appreciated, as I have been struggling with this for a while.

Important Summary Notes: 1.) Application runs as desired on simulator. 2.) handleOpenURL Method not called when I request it from my AppDelegate. 3.) I do not receive any errors/warnings. 4.) I can run the DemoApp on my device, and I notice that the handleOpenURL Method is called appropiately when requested by the 'DemoAppAppDelegate.'

Thanks in Advance!

解决方案

I ended up having to make my facebook object a singleton (stored in the appDelegate). Not completely sure why this was necessary though, as I was not using the fb object in multiple viewControllers. Please comment if you know why this was necessary.

See the following links for more information:

handleOpenUrl and TabBar Application

Facebook SDK: Call from multiple viewControllers

Cocoa with Love: Singletons

这篇关于FBConnect的handleOpenURL方法未被我的AppDelegate调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆