アプリケーションに branch.io を実装しました。アプリがバックグラウンドで実行されておらず、branch.io リンクがクリックされた場合を除いて、正常に動作します。アプリが開き、共有コンテンツが表示される画面にリダイレクトされますが、空の画面または画面にコンテンツが表示されません。アプリがバックグラウンドで実行されている場合、正常に動作します。なぜそれが制限なのか、何かが足りないのですか。よろしくお願いします。
わかりやすくするためにいくつかのコードを投稿します。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
sleep(5);
ArticlesDetailViewController *controller = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"articlesDetail"];
Branch *branch = [Branch getInstance];
[branch registerDeepLinkController:controller forKey:@"ScreenArticle"];
[branch initSessionWithLaunchOptions:launchOptions automaticallyDisplayDeepLinkController:YES];
}
// Controller where redirected.
- (void)configureControlWithData:(NSDictionary *)data {
NSString *pictureUrl = data[@"ScreenArticle"];
iSBranch = 1;
strDate = data[@"CreatedDate"];
self.lblDate.text = [strDate uppercaseString];
self.lblTitle.text = data[@"Title"];
strDesc = data[@"Description"];
[self.txtDescription sizeToFit];
[self.txtDescription.textContainer setSize:self.txtDescription.frame.size];
NSString *strPreFont = @"<font face=\"Avenir Next\" color=\"#FFF\" size=\"5\">";
NSString *strPost = @"</font>";
NSString *htmlString = [NSString stringWithFormat:@"%@%@%@", strPreFont, strDesc, strPost];
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUTF16StringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
self.txtDescription.attributedText = attributedString;
strImgUrl = data[@"ImageName"];
[self.imgHeader sd_setImageWithURL:[NSURL URLWithString:strImgUrl] placeholderImage:[UIImage imageNamed:@"DummyImageFeaturedFirst"]];
// show the picture
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:pictureUrl]];
UIImage *image = [UIImage imageWithData:imageData];
dispatch_async(dispatch_get_main_queue(), ^{
//self.productImageView.image = image;
NSLog(@"got image");
});
});
}
- (IBAction)closePressed {
[self.deepLinkingCompletionDelegate deepLinkingControllerCompleted];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
mixpanel = [Mixpanel sharedInstance];
if(iSBranch)
{
}
else
{
self.lblDate.text = [strDate uppercaseString];
self.lblTitle.text = strTitle;
//self.txtDescription.text = strDesc;
[self.txtDescription sizeToFit];
[self.txtDescription.textContainer setSize:self.txtDescription.frame.size];
NSString *strPreFont = @"<font face=\"Avenir Next\" color=\"#FFF\" size=\"5\">";
NSString *strPost = @"</font>";
NSString *htmlString = [NSString stringWithFormat:@"%@%@%@", strPreFont, strDesc, strPost];
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUTF16StringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
self.txtDescription.attributedText = attributedString;
[self.imgHeader sd_setImageWithURL:[NSURL URLWithString:strImgUrl] placeholderImage:[UIImage imageNamed:@"DummyImageFeaturedFirst"]];
}
}