Instagram故事分享无法通过登录页面获取

时间:2018-10-19 13:01:57

标签: objective-c xcode instagram instagram-api

我有一个应用,用户正在与该应用共享屏幕截图。该应用程序已上线,并且运行正常。如今,我意识到当用户单击instagram故事共享时,它仅进入登录页面。即使用户登录到instagram并从我的应用程序中重新单击以共享故事,它仍然会转到instagram登录页面。那是什么问题?

- (IBAction)instagramClicked:(id)sender
{
    [FIRAnalytics logEventWithName:@"instagram_share"
                        parameters:@{
                                     @"name": @"instagram_share",
                                     @"full_text": @"instagram_share"
                                     }];

    [self backgroundImage:UIImagePNGRepresentation([self getScreenshot])
           attributionURL:@"abcapp://"];
}

//Get image of the view
- (UIImage *)getScreenshot {
    CGRect rect = [_shareView bounds];
    UIGraphicsBeginImageContextWithOptions(rect.size,NO,2.0f);
    CGContextRef context = UIGraphicsGetCurrentContext();
    [_shareView.layer renderInContext:context];

    UIImage *capturedScreen = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return capturedScreen;
}

- (void)backgroundImage:(NSData *)backgroundImage
         attributionURL:(NSString *)attributionURL {

    // Verify app can open custom URL scheme, open if able
    NSURL *urlScheme = [NSURL URLWithString:@"instagram-stories://share"];
    if ([[UIApplication sharedApplication] canOpenURL:urlScheme]) {

        // Assign background image asset and attribution link URL to pasteboard
        NSArray *pasteboardItems = @[@{@"com.instagram.sharedSticker.backgroundImage" : backgroundImage,
                                       @"com.instagram.sharedSticker.contentURL" : attributionURL}];
        NSDictionary *pasteboardOptions = @{UIPasteboardOptionExpirationDate : [[NSDate date] dateByAddingTimeInterval:60 * 5]};
        // This call is iOS 10+, can use 'setItems' depending on what versions you support
        [[UIPasteboard generalPasteboard] setItems:pasteboardItems options:pasteboardOptions];

        [[UIApplication sharedApplication] openURL:urlScheme options:@{} completionHandler:nil];
    } else {
        // Handle older app versions or app not installed case
    }
}

1 个答案:

答案 0 :(得分:1)

这是Instagram应用程序当前版本的错误。您必须等待更新,甚至在与Instagram共享时,甚至Boomerang之类的应用也已损坏。