butchmarshall / react-native-google-nearby-connection Goto Github PK
View Code? Open in Web Editor NEWReact Native wrapper for the google nearby connection api
License: MIT License
React Native wrapper for the google nearby connection api
License: MIT License
This package is not support on React native version 0.62.2
Hey,
We have created a new repo that we are maintaining with hooks and cross platform capabilites. Check it out here: https://github.com/mrousavy/react-native-google-nearby-messages
Hey Butch, first need to say amazing library!
I have a question regarding the ability to call Nearby.saveFile(serviceId,endpointId,payloadId)
after an initial permission failure. Currently, as long as a user has granted permissions to READ/WRITE external storage, calling Nearby.saveFile()
has the promise resolve successfully. If permissions are not granted or are revoked before calling saveFile, one encounters a promise rejection. Until here things are still behaving as expected.
However, in my case I am trying to offer the user the ability to retry executing saveFile()
at a later point by storing the serviceId
, endpointId
, and payloadId
before initially calling saveFile. This way, once saveFile()
is called and it fails, the user can be prompted to grant permissions within their settings or elsewhere and try calling it again. The problem is that when I allow the user to retry using the same serviceId
, endpointId
, and payloadId
which previously failed due to permissions not being granted, the promise still rejects.
When I adb logcat
I see it is failing with the message 03-24 14:31:03.806 24644 26856 V NearbyConnection: Cannot convert to file.
, which is line #1501 here
In other words it seems that
File payloadFile = payload.asFile().asJavaFile();
is null
. I decided to log every payload variable until permissionsCheck
fires and this is the below output:
03-24 14:31:03.805 24644 26856 V NearbyConnection: saveFile from service com.google.myApp.v1 and endpoint hT4- and payload -6821529802993021226
03-24 14:31:03.805 24644 26856 V NearbyConnection: Payload com.google.android.gms.nearby.connection.Payload@16edba2
03-24 14:31:03.805 24644 26856 V NearbyConnection: payload.getType() 2
03-24 14:31:03.805 24644 26856 V NearbyConnection: payloadFileData awesomePhoto.WEBP:{"description":"a flower"}
03-24 14:31:03.805 24644 26856 V NearbyConnection: payloadFilename awesomePhoto.WEBP
03-24 14:31:03.805 24644 26856 V NearbyConnection: payloadMetadata {"description":"a flower"}
03-24 14:31:03.806 24644 26856 V NearbyConnection: Cannot convert to file.
Question/s: Any idea why payload.asFile().asJavaFile()
returns null when retrying saveFile
? Is it that the initial permissions failure causes the payload content to somehow be destroyed within the NearbyConnection cache so there is nothing to call payload.asFile().asJavaFile()
on? Although I find it strange that calling payload.getType()
works and other metadata still exists on the payload but asFile()
fails. Any thoughts here would be amazing.
Assumption/Hypothesis: After the final payload is delivered, Nearby Connections attempts to write the file which, if the permissions are not given, fails. Therefore, regardless if permissions are then granted after, that final payload will still not have a file associated and, as such, will forever fail. If this is correct then there is no other option than to resend the file I'm guessing.
Stackoverflow link: https://stackoverflow.com/questions/55328027/nearbyconnection-payload-asfile-asjavafile-is-null-when-retrying-to-savefil
Wanted to check if the package is still being supported and worked on?
Hi, butchmarshall
I tried to run your example into more recent google nearby. I spent a couple of days to tackle this and updated most of the Gradle and SDK versions to the most recent versions and it is building the app successfully except for this runtime error. I am using "react-native": "0.61.5".
renderApplication.js (this file is part of React-Native and hasn't been modified in any way)
index.js
class NearbyConnection {
// Get all the endpoints
static endpoints() {
return NativeModules.NearbyConnection.endpoints(); // <- issue is here
}
App.js
componentWillMount() {
Nearby.endpoints().then(endpoints => {
console.log('endpoints', endpoints);
});
}
Could you please take a quick look and point me in the right direction? Thanks!
my fork is in https://github.com/staminna/react-native-google-nearby-connection
Is this wrapper for Android only?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.