gpt4 book ai didi

ios - ShareKit - 在 Facebook 上分享

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:42:57 34 4
gpt4 key购买 nike

我正在使用 ShareKit 在 Facebook 上分享一个简单的文本。我使用 cocoapods 在我的应用程序(使用 iOS7 和 XCode5)上安装 ShareKit,并遵循配置教程 ConfigurationShareKit .更具体地说,我做了以下事情:

1) 将URL Scheme写入plist。

2) 创建一个 DefaultSHKConfigurator 子类:

@interface MySHKConfigurator : DefaultSHKConfigurator@end@implementation MySHKConfigurator- (NSString*)facebookAppId{    return @"xxx";}-(NSString *)appName{    return @"MyAppName";}- (NSArray*)facebookWritePermissions{    return [NSArray arrayWithObjects:@"publish_actions",@"publish_stream", nil]; //@"offline_access",}- (NSArray*)facebookReadPermissions{    return nil; // this is the defaul value for the SDK and will afford basic read permissions}@end

3) 在 AppDelegate 中进行初始配置:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    // Override point for customization after application launch.        DefaultSHKConfigurator *configurator = [[MySHKConfigurator alloc] init];    [SHKConfiguration sharedInstanceWithConfigurator:configurator];    //[SHK flushOfflineQueue];        return YES;}- (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.    [SHKFacebook handleDidBecomeActive];}- (void)applicationWillTerminate:(UIApplication *)application{    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.    // Save data if appropriate    [SHKFacebook handleWillTerminate];}- (BOOL)application:(UIApplication *)application            openURL:(NSURL *)url  sourceApplication:(NSString *)sourceApplication         annotation:(id)annotation{    NSString* scheme = [url scheme];        if ([scheme hasPrefix:[NSString stringWithFormat:@"fb%@", SHKCONFIG(facebookAppId)]]) {        return [SHKFacebook handleOpenURL:url];    }    return YES;}

4) 在 Facebook 上分享

- (IBAction)shareFacebook:(id)sender {                //- The url should be a link to your app on the app store    NSURL *url = [NSURL URLWithString:@"http://www.google.com"];    //- Share on Facebook    SHKItem *item = [SHKItem URL:url title:self.textView.text contentType:SHKURLContentTypeWebpage];    [SHKFacebook shareItem:item];    }

现在,我在真实设备上得到的结果是一个带有问题的 facebook 确认对话框:“您已经授权 MyApp”。在我按下确定按钮后,它返回到共享对话框。在我按下“发送到 Facebook”后,它再次返回到带有上述问题的 Facebook 确认对话框。这个循环永远循环下去。

你知道我错过了什么吗?谢谢

最佳答案

哦,我现在明白了——如果你更喜欢直接调用分享者,而不是打电话

[SHKiOSFacebook shareItem:item];

SHKFacebook和SHKiOSFacebook的区别在于前者使用Facebook iOS SDK,后者使用Accounts.framework和Social.framework。

关于ios - ShareKit - 在 Facebook 上分享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24259516/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com