我在尝试登录Google Plus时遇到问题,在返回应用程序后发送我的用户和密码后,我的应用程序崩溃了。
错误发生在这一行:
BOOL openURL(id self, SEL _cmd, UIApplication* application, NSURL* url, NSString* sourceApplication, id annotation){
[GPPURLHandler handleURL:url sourceApplication:@"com.google.chrome.ios" annotation:nil];
}
//...
我进入设备控制台:
:***因未捕获的异常而终止应用 'NSInvalidArgumentException',原因:'无法创建 NSPersistentStoreCoordinator与nil模型'
然后使用控制台中打印的网址尝试:
NSURL *fixedURL = [NSURL URLWithString:@"com.domain.xxxxxx:/oauth2callback?state=75029341&code=4/hy789ysdfhfRA8cuIeHbO0fP3p1oXcFeCnYJe--vZgc.klaHKD1A8zws76f7678df6782M1BcwvNlQI&authuser=0&num_sessions=1&prompt=consent&session_state=dca3e8a678sdf678a6f7d880e02bcf5155e5822c038..5f88"];
[GPPURLHandler handleURL:fixedURL sourceApplication:@"com.google.chrome.ios" annotation:nil];
//...
这些代码没有任何反应
然后我尝试:
NSString *urlString =[NSMutableString stringWithFormat:@"%@:/oauth2callback?%@", [url scheme],[url query]];
NSURL *fixedURL = [NSURL URLWithString:urlString];
//...
得到第一个错误。
属性列表键中的
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.domain.xxxxxx</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.domain.xxxxxx</string>
</array>
<key>CFBundleURLTypes</key>
<string>Editor</string>
</dict>
</array>
<key>GPGApplicationID</key>
<string>123123123-0fnaerghgic4er3g9cmn045daasl0u1u.apps.googleusercontent.com</string>
我做错了什么?
答案 0 :(得分:0)
我不确定您为什么要尝试为此方法制作参数,或者您尝试调用它的地方。您的UIApplicationDelegate
附加了@optional
响应者:
- (BOOL)application:(UIApplication *)application openURL:(NSURL*)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
此处将调用GPPURLHandler
的用例(当激活已注册的URL方案时,操作系统会将其调用到您的应用程序中)。这将进入您的UIApplicationDelegate
实施:
- (BOOL)application:(UIApplication *)application openURL:(NSURL*)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation];
}