How to set up Branch subscription

#1

I tried following the instructions at https://docs.expo.io/versions/latest/sdk/branch.html, but I’m not able to find the Branch module in DangerZone.

Here’s what my code looks like:

import { DangerZone } from 'expo'

componentDidMount() {
    const { Branch } = DangerZone

   Branch.subscribe(bundle => {
      if (bundle && bundle.params && !bundle.error) {
        // `bundle.params` contains all the info about the link.
      }
    })
  }

I get an error that says:
[ts] Property 'Branch' does not exist on type 'typeof DangerZone'.

Any my dependency looks like:
"expo": "25.0.0",

What am I doing wrong?

#2

That looks right. Exactly what I have in mine. The subscribe function doesn’t work on Android anyway though. (react-native-branch implementaiton issue, not expo)

#3

Yeah I don’t see anything obviously wrong with that code @jabdulius. Can you repro that error in a snack? I know branch won’t actually work in a snack but it would be useful if we could see the error.

#4

Thanks Christian, Jesse. I cannot repro in a snack. We are using Typescript in our project, but I’m a bit of a newb. Might that have something to do with it, and is it possible to test Typescript in a snack?

Snack:
https://snack.expo.io/H1K5NGvYG

closed #5

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.