Implemented the branch.io in the application. Working fine except if app is not running in background and branch.io link clicked. It will open the app and redirect to the screen where shared content to be shown but showing the empty screen or no content on screen.If app is running in background it works fine. Why so is it the limitation or i am missing something.
Please guide, thanks in advance.
Posting some code for clarity.
- (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"]];
}
}