question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No data passed on resume

See original GitHub issue

Hello,

If my Ionic App is open in background, and I click on a branch link in another app, Branch.initSession() is returning me this, after I called it on the platform.resume event.

{"+clicked_branch_link":false,"+is_first_session":false}
branchInit() {
    console.log('branchInit');
    // only on devices
    if (!this.platform.is('cordova')) { return }
    const Branch = window['Branch'];
    Branch.initSession(this.checkDeeplink.bind(this));
    //Branch.getLatestReferringParams().then(this.checkDeeplink.bind(this));
    //Branch.getFirstReferringParams().then(this.checkDeeplink.bind(this));
    
  }

  checkDeeplink(res) {
    console.log(JSON.stringify(res));
    if(res['+clicked_branch_link']) {
      console.log('here');
      this.nav.push('reset-password');
    }
  }

  constructor(public platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, public menu: MenuController) {
    if (localStorage.getItem('access_token')) {
        this.rootPage = ListPage;
    }
    
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();      
      this.branchInit();
    });

    platform.resume.subscribe(() => {
      this.branchInit();
    });
  }

My goal is to show a “Reset Password Page” after clicking a Branch deep link, wether or not the app is launched in background.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
captaincolecommented, Jan 5, 2018

@ethanneff Thanks for getting back to us. Here is the information requested. By the way, adding a small 300ms timeout to my code actually made it work…

The deeplink specifically being used, which was created via “quick links” on the branch dashboard (as opposed to an in-app link)

https://38plank.app.link/donated (this wont work in our current app because were building a whole new flow)

Were using this deeplink to route people back from a donation webpage to our app. It does not work the first time I go back to the app, but if I do the same process a second time, it will work.

Here is the relevant code that is used on resume, and on init

      const branchInit = () => {
        if (!platform.is('cordova')) { return; }
        console.log('Init Session Branch');
        Branch.initSession( (data) => {
          console.log('Branch Initialized' + JSON.stringify(data));
          if (data.$deeplink_path) {
            console.log('Routing Link: ' + JSON.stringify(data.$deeplink_path));
            this.routeLink(data.$deeplink_path);
          }
        }).then( (data) => {
          console.log('Branch Init' + JSON.stringify(data));
        }).catch( (err) => {
          console.log('Branch Init Error: ' + JSON.stringify(err));
        });
      };

      branchInit();
      Branch.setDebug(true);
      platform.resume.subscribe( () => {
        platform.ready().then( () => {
          console.log('Branch resume');
            branchInit();
        });
      });

Wish I knew how to attach those fancy screen videos you are using above. Is that just a video from an emulator?

1reaction
spacesuitdivercommented, Jan 2, 2018

@alexandre-pereira @ethanneff wrapping this in a timeout as shown below seems to alleviate the issue so there’s some sort of race condition going on it seems.

                setTimeout(() => {
                    $window.Branch.initSession(function (data) {
                        console.log(data); 
                    })
                    .then(console.log)
                    .catch(console.log);
                }, 5000);

Read more comments on GitHub >

github_iconTop Results From Across the Web

No data passed on resume · Issue #411 - GitHub
Hello, If my Ionic App is open in background, and I click on a branch link in another app, Branch.initSession() is returning me...
Read more >
How to Quantify Your Resume Bullets - The Muse
No matter what you do for a living, you can always quantify your resume bullet points to help your resume stand out to...
Read more >
15 Things You Should Not Include in a Resume - TopResume
What you decide to not include in a resume is just as important as what you choose to include. Here's a list to...
Read more >
The 10 Worst Resume Mistakes to Avoid - Monster Jobs
Whether you're writing your first resume or tenth, no one is immune from making a mistake or two. Check our list of common...
Read more >
11 Things You Shouldn't Include on Your Resume | Indeed.com
11 things not to put on your resume · 1. Too much information · 2. A solid wall of text · 3. Spelling...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found