New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[expo-branch] null is not an object (evaluating RNBranch.STANDARD_EVENT_ADD_TO_CART #5349
Comments
You'll want to run
|
This works on iOS but still results in the same screen (shown in OP) on Android. I've updated https://github.com/AryanJ-NYC/expo-sandbox to reflect the changes you suggest. |
We state in Expo's Branch docs:
|
I see. I was under the impression that Branch was re-added as an optional module for Android. |
That will probably go out with SDK 35 |
I don't this is an issue that will be fixed with Expo SDK 35. Instead, it's a bug in the I think this issue should be re-opened. @sjchmiela, thoughts? |
This hasn't been communicated clearly anywhere, since we haven't announced this feature publicly yet, but when trying to use Branch you will need to remember that:
Has this description helped understand current situation? 😅 |
Yes, it has, @sjchmiela. This would mean that, while if (Constants.appOwnership === 'standalone') {
const { BranchEvent } = await import('expo-branch')
const branchEvent = new BranchEvent(eventType, null, properties) // assume properties is defined
branchEvent.logEvent()
} which now does not return the same error as above. Unfortunately, I'm still unsuccessfully able to run a built app. Will keep updated. |
That's right, that should do the work! To inspect whether |
I can confirm that Additionally, trying to Lastly, I can also confirm that I logged the non-existence of a default export here: #5348 |
I've found |
I'm stuck with the same problem. I'm trying with SDK 35 and still getting that error on IOS and Android.
and
I read about the Android support here, and followed this instructions. error: i'm missing something? |
Branch is only included in standalone apps ( |
Thanks for the reply, @sjchmiela! Please, correct me if I'm wrong. Thanks EDIT: |
Just want some clarification on @sjchmiela reply. So since there is no support with the Expo client, would that mean in order to test branch functionality (for iOS) we would have to do a standalone build and upload to Testflight? Is there any other workflow for this at the moment? And is Expo client support for branch something in the works? Thanks for your help. |
Same here. We can´t test in in the iOS Simulator? |
Correct, you can't test in the Expo Client, but you can install your binary onto a simulator before moving on to TestFlight, if you wish |
Branch doesn't work for me even in standalone builds. I tried iOS only.
|
Did you tried to import it direct for testing? without condition. |
@davidbiller do you mean the regular import without Just tried |
//import Branch from "expo-branch"; this works for me. |
@davidbiller are you using expo v35? |
Yes. So what error do you get? |
I get the following error:
|
so you do the import with branch and not Branch |
@davidbiller it used to be Here is the error I get from sentry:
with the following code:
I don't know what error I get when importing branch the regular way because it doesn't get reported to sentry. App just crashes on launch. |
Looks like you dont use it in a standalone app, without expo. |
@davidbiller I'm doing a build with |
mhhh okay. |
@davidbiller I don't know why, but it works now. I import it with regular top import and I left the Thank you! I spent about 5 hours on this. |
So I have struggled a lot with this issue and tried both sdk 34 as well as 35. Now I've got it up and running (functional in standalone app and error-less build in expo-cli for development purpose) This error will appear only if actively importing Branch from 'expo-branch' in any module at the time of building the app. So a simple conditional if(Constants.appOwnership === 'standalone') { |
@yodaheis Just be aware that const someAsyncFunction = async () => {
if(Constants.appOwnership === 'standalone') {
const Branch = await import('expo-branch')
// Your code here ...
}
} |
I'm running this on a standalone app on my device, expo 35, and getting a Also, when importing normally(without the standalone condition), and running as standalone on a device, the code within subscribe doesn't run, even when opening from a branch url. Any pointers? |
To import dynamically using const ExpoBranch = await import('expo-branch')
const Branch = ExpoBranch.default;
Branch.setIdentity('user_id') |
I tried importing as @0duaht suggested, but am still getting an error on importing the library: Not sure what i'm doing wrong? // ./Branch.js
import { Alert } from 'react-native';
import Constants from 'expo-constants';
(async function(){
if (Constants.appOwnership === 'standalone') {
const ExpoBranch = await import('expo-branch')
const Branch = ExpoBranch.default;
Alert.alert(`branch ${typeof ExpoBranch} | ${typeof Branch}`)
// Branch.subscribe((bundle) => {
// Alert.alert(`bundle ${typeof bundle}`, JSON.stringify(bundle))
// if (bundle && bundle.params && !bundle.error) {
// Alert.alert(`bundle exists ${typeof bundle}`, JSON.stringify(bundle))
// console.log(bundle.params)
// }
// });
}
})() Update, i've finally made it work. Perhaps because i didn't have the correct |
Also, for those interested, I've ended up handling it this way: // /my-branch.js
import Constants from 'expo-constants';
if (Constants.appOwnership !== 'standalone') {
module.exports = {
subscribe: console.log,
createBranchUniversalObject: async () => ({
showShareSheet: console.log,
})
}
}
else{
module.exports = require('expo-branch')
} and then |
I struggled getting the syntax correct to export the nested
|
Hello! is there any experienced dev here that can help me with expo & branch implementation? Please contact me at augusto@lemmonet.com to discuss collaboration fees ... thanks! |
Hey @walidvb , I am new to branch and expo.I am trying to integrate branch on expo v36 for android. I am not quite clear on those function implementations. Can you please elaborate on it? |
@Winnie16 the idea is to conditionally load branch, depending on your environment. Across your codebase, instead of doing I'm now adding branch for web, and seeing that this will be needed either way, as they have quite different implementations. In this case, I will have a Makes sense? |
Yes this does make things clear. Can you give me an idea about mocking the functions? |
As per my previous post, which only mocks |
Hello @walidvb / @Winnie16 Here is my app.js code, as you can see I'm logging with Sentry: import React from 'react'; Sentry.init({ class App extends React.Component { async componentDidMount() {
} render() { ); } } export default App; |
@SirPhemmiey share your code? Were you able to see the error? Can you run in debug? @augustolp Haven't played much with the link attribution on their dashboard, but I can confirm I can most of the time my app can retrieve the data of the link. I save these on the server, too, and i can usually see that I want to point out that Branch is not a good solution if you plan a web release too, as it is blocked by adblockers, breaking the |
Hi @walidvb , thanks for your response. Below is the code I'm using
And I'm importing it normally as in:
Thanks for your help |
@SirPhemmiey i'm not expert enough in js to have a proper answer, but why the wrap in async? Could be the issue. I think expo has added conditional and/or async imports recently, but i don't know how it works exactly, or whether it is already available in the latest SDK |
Hi @walidvb , i removed the async and it was still the same when I made a new build. It was still crashing when I opened it. And when I checked the logs via |
@SirPhemmiey it's difficult to tell without a crash log. Build your app in debug mode and see what that says. |
Hello everyone. Thanks to a number of comments, I now handle the Branch code in dev and production environments. But can anyone please help me to set up a simple thing? I need to count installs. Expo 40, managed workflow.
As a result – nothing on my dashboard.branch.io: no installs, no opens, nothing. |
🐛 Bug Report
Environment
This bug happens in Android
Steps to Reproduce
import * as whatever from 'expo-branch'
OR
import whatever from 'expo-branch'
OR
import { Branch } from 'expo-branch'
npm start
Expected Behavior
It does not break.
Actual Behavior
It breaks.
Reproducible Demo
https://github.com/AryanJ-NYC/expo-sandbox
The text was updated successfully, but these errors were encountered: