Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all 16553 articles
Browse latest View live

Get the length between two dates in hours

$
0
0

I am reading sleep data into my react-native app using react-native-healthkit, and I need to find a way to get the total amount of sleep time. The data is read in like this:

js object

If anyone has any ideas on the best way to handle this data, please let me know.


React-Native play video using expo sdk

$
0
0

I want to play a video from url using expo sdk for react native.I read the sdk but I am unable to understand how to make it work. Here is link for expo sdk video docs.

Here is my code

 import React from 'react';
import { StyleSheet, Text, View,Button } from 'react-native';
import { Video } from 'expo';

export default class App extends React.Component {
    _handleVideoRef = component => {

    }

    onPlayPressed(){

    }

  render() {

    return (
      <View style={styles.container}>
            <Expo.Video
            source = {{uri :'url for video'}}
            ref={this._handleVideoRef}

            />
            <Text>Open up App.js to start working on your app! </Text>
            <Button onPress={this.onPlayPressed.bind(this)} title = "Play"/>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

Doc says video tag works as inline but I am not sure why it not playing video or anything more is needed.

Thanks for any help

How do I address React Native network requests failing after upgrading to HTTPS?

$
0
0

I've been developing a React Native app and most of my functionality is now in place. The backend is a REST API written in Kotlin using the Spark microframework on top of a PostgreSQL database. The app was first written using react-native init before Expo was a thing. I've been using iOS to test the app as I develop it, although the code is pure React Native so porting to Android shouldn't be a massive problem.

When my REST API server was running on localhost:1337 my app experienced no problems whatsoever, however yesterday I deployed to an EC2 instance and secured it using a certificate obtained via letsencrypt (using a Java keystore). Manual queries to the API via the web browser work perfectly (and the certificates are valid) and the queries also work on the Safari browser within the iOS Simulator, but on the simulated React Native app every request now fails since I've pointed them to my new server. The GET requests fail with a warning promise rejection: network request failed and the POST requests fail with a crash and the same error. The requests are given in the form:

var url = "https://example.com/api/posts?lat=" +
    lat + "&lon=" + lon;
    this.setState({url: url});

    const bar = this;
    fetch(url) 
    .then(response => response.json())
    .then(data => {
      var foo = JSON.stringify(data);
      this.setState({ posts: foo});
    })
    .catch((err) => {
      console.log(err)
      reject(err)
    });

I've done all of the usual React Native generic solutions like wiping and rebuilding my ios/build directory, re-installing all my Node modules and even adding an exception to my domain in info.plist (even allowing insecure requests generally, which I think is a bit of a black mark when applying for App Store approval) to no avail whatsoever. When I get home I intend to probe the connection with Wireshark but as the requests are failing immediately without any delay I expect it'll only confirm my suspicion that the requests don't go up at all and are being denied by iOS for some reason. Most of the questions I've seen in my debugging efforts talk about HTTPS working and HTTP failing, which is easily solvable by setting a variable in the iOS config. I've not come across this, the opposite problem in any recent version of React Native.

Any advice with this issue would be much appreciated, I'm really tearing my hair out here. Thanks in advance.

Is it possible to detect if an app in AppStore is developed with React Native?

$
0
0

For Android there are a few decompiling applications such as Show Java. We are able to understand which platform used for the development of that Android app. Is there any way to understand if an iOS app developed by React Native or not ? Or can we detect which platform used to develop that iOS app ?

XCode Linker command failed - Directory not found

$
0
0

I am using auth0 on a React Native iOS project, and I have completed the following steps:

First you need to run the following command to install react-native-lock npm install --save react-native-lock

After that, link react-native-lock with your iOS project: react-native link react-native-lock

When running the above, cocoapods installs a few dependencies which all install successfully:

Adding Podfile to iOS project
Installing Pods
Analyzing dependencies
Downloading dependencies
Using AFNetworking (3.1.0)
Using Lock (1.28.2)
Using Masonry (0.6.4)
Using SimpleKeychain (0.7.0)
Using TouchIDAuth (0.2.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 4 dependencies from the Podfile and 5 total pods installed.

In my Project > Build Settings > Other Linker Flags I have:

lc++
${inherited}
-ObjC

However, when I build the project to my physical iPhone, I get this error for every installed dependency:

ld: warning: directory not found for option '-L/Users/dan/Library/Developer/Xcode/DerivedData/myapp-acmwajylejkvendtsdryuouwuvnl/Build/Products/Debug-iphoneos/AFNetworking'

Could anyone help me with resolving this error please?

If I open my app and close it again so fast, when I come back to it, all the data is reset

$
0
0

I'm having a problem that's not dramatic, but it's a little annoying anyway.

If I open my application (it's basically killed) and I cut it directly (like really fast), and then I click on it again to open it, there are times when even though I was logged in, I find myself on the login page because the application seems to have deleted all the data stored in the storages.

I have absolutely no error, and I can only reproduce this behavior in production, so it's hard to catch an error.

It's a behavior that is difficult to reproduce on phones except on the iPhone SE which seems to be much more reactive, so there is a way to shut down the app extremely quickly!

Has anyone ever encountered this problem before?

Thanks

Viktor

How to building React Native App using WebRtc

$
0
0

Thank you for your help in advance.

I want to make a new WebRtc mobile application for video calling using react native, i checked many articles but not getting exact information how to start. Can any person please help me and guide me the path to create an application.

EPERM: operation not permitted, chmod @react-native-community iOS

$
0
0

I am using React 16.8.6 and react-native 0.59.6. iOS.

While typing react-native --version or anything prefix with react-native, it is showing the following error.

internal/fs/utils.js:220
    throw err;
    ^

Error: EPERM: operation not permitted, chmod '/usr/local/lib/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/server/external/xsel'
    at Object.chmodSync (fs.js:1104:3)
    at Object.<anonymous> (/usr/local/lib/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/server/copyToClipBoard.js:50:15)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/server/middleware/copyToClipBoardMiddleware.js:8:47)
    at Module._compile (internal/modules/cjs/loader.js:956:30) {
  errno: -1,
  syscall: 'chmod',
  code: 'EPERM',
  path: '/usr/local/lib/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/server/external/xsel'
}

I cleaned the project. Restarted it.

Deleted npm package and reinstalled it.

Tried npm install -g react-native-cli.

I have react-native-community/cli version 1.12.0 in package.lock.json dependancies.

I don't have any clue about what to do. I am not able to do link any libraries and other stuffs which requires react-native keyword.

Moreover, If I run it with sudo like sudo react-native --version, it is giving like below mentioned.

warn Your project is using deprecated "rnpm" config that will stop working from next release. Please use a "react-native.config.js" file to configure the React Native CLI. Migration guide: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
warn The following packages use deprecated "rnpm" config that will stop working from next release:
  - react-native-google-signin: https://github.com/react-native-community/react-native-google-signin
  - react-native-video: https://github.com/react-native-community/react-native-video#readme
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
3.0.4

Please suggest some guidance regarding the same.

Thanks.


React Native IOS Status Bar background

$
0
0

Since Applying the backgroundColor props to StatusBar component doesn't get applied On IOS. I need to set the background colour of SafeAreaView to get the effect i want, it works fine but on iPhone X it will have that same colour at the bottom of the screen. How can I solve this issue?

enter image description here

Open Url in default web browser

$
0
0

I am new in react-native and i want to open url in default browser like Chrome in Android and iPhone both.

We open url via intent in Android same like functionality i want to achieve.

I have search many times but it will give me the result of Deepklinking.

react-native How to open local file url using Linking?

$
0
0

I'm using the following code to download a file (can be a PDF or a DOC) and then opening it using Linking.

const { dirs } = RNFetchBlob.fs;
let config = {
    fileCache : true,
    appendExt : extension,
    addAndroidDownloads : {
        useDownloadManager : false,
        notification : false,
        title : 'File',
        description : 'A file.',
        path: `${dirs.DownloadDir}/file.${extension}`,
    },
};
RNFetchBlob.config(config)
    .fetch(
        method,
        remoteUrl,
        APIHelpers.getDefaultHeaders()
    )
    .then((res) => {
        let status = res.info().status;
        if (status == 200) {
            Linking.canOpenURL(res.path())
                .then((supported) => {
                    if (!supported) {
                        alert('Can\'t handle url: ' + res.path());
                    } else {
                        Linking.openURL(res.path())
                            .catch((err) => alert('An error occurred while opening the file. ' + err));
                    }
                })
                .catch((err) => alert('The file cannot be opened. ' + err));
        } else {
            alert('File was not found.')
        }
    })
    .catch((errorMessage, statusCode) => {
        alert('There was some error while downloading the file. ' + errorMessage);
    });

However, I'm getting the following error:

An error occurred while opening the file. Error: Unable to open URL:file:///Users/abhishekpokhriyal/Library/Developer/CoreSimulator/Devices/3E2A9C16-0222-40A6-8C1C-EC174B6EE9E8/data/Containers/Data/Application/A37B9D69-583D-4DC8-94B2-0F4AF8272310/Documents/RNFetchBlob_tmp/RNFetchBlobTmp_o259xexg7axbwq3fh6f4.pdf

I need to implement the solution for both iOS and Android.

Cant run pod install in windows for react native

$
0
0

c

I have already installed cocoapods and ruby but still dont get what i m doing wrong can somebody lease help me. I m using it for navigation

Undefined symbols for architecture arm64: _YGConfigNew in libyoga.a(Yoga.o)

$
0
0

When I launch my app with XCode or with react-native run-ios in an iOS emulator, it work good.

But if I do the same in a real device, it not work. I've got this error :

Undefined symbols for architecture arm64:
   "YGConfig::YGConfig(int (*)(YGConfig*, YGNode*, YGLogLevel, char const*, char*))", referenced from:
      _YGConfigNew in libyoga.a(Yoga.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

More informations :

react: 16.9.0
react-native: 0.60.5
Real device: iPad with iOS 12.4.4

Someone has solution ? Thanks

Pubnub preventing detox syncing

$
0
0

Need some help with Detox. I’ve got a similar issue to https://github.com/wix/detox/issues/272



We have a Pubnub publish-subscribe SDK included in our app. So, when running a detox test, it will always time out, because it will wait for the connection to close.

I’ve tried both setURLBlacklist on launch and detoxURLBlacklistRegex but with no luck. The logs still say:

[com.wix.Detox:EarlGreyStatistics] App State -> busy Waiting for network requests to finish: (
    "https://ps15.pndsn.com/v2/subscribe/sub-c-xxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”

I’m fairly positive my regex is correct. The regex mentioned in the issue mentioned above doesn’t work. I wouldn't normally ask for help with simple regex, but my knowledge of EarlGrey is minimal and i've been battling with this for a while.

I need to ignore all requests made to ps[0-9][0-9].pndsn. A little help with the regex, or Blacklist array would be much appreciated.

  await device.launchApp({permissions: { notifications: 'YES' }, launchArgs: { 'detoxPrintBusyIdleResources': 'YES' , 'detoxURLBlacklistRegex' : '\\(".*pndsn.com.*"\\)'}});
  await device.setURLBlacklist([".*ps1.pndsn.com.*",".*ps2.pndsn.com.*",".*ps3.pndsn.com.*",".*ps4.pndsn.com.*",".*ps5.pndsn.com.*",".*ps6.pndsn.com.*",".*ps7.pndsn.com.*",".*ps8.pndsn.com.*",".*ps9.pndsn.com.*",".*ps10.pndsn.com.*",".*ps11.pndsn.com.*",".*ps12.pndsn.com.*",".*ps13.pndsn.com.*",".*ps14.pndsn.com.*",".*ps15.pndsn.com.*",".*ps16.pndsn.com.*",".*ps17.pndsn.com.*",".*ps18.pndsn.com.*",".*ps19.pndsn.com.*.",".*ps20.pndsn.com.*"]);

Note: If I disable synchronisation the app hangs on initialisation. This is for an iOS app.

react native store notification data when app is close or in backaground

$
0
0

I'm trying to build a react native app that includes chat, I'm using realm for storing my data on the device, and FCM to get a remote notification with 'react-native-firebase'.

I would like to know if there is any way that I can save the data of the remote notification to realm without entering the app or to the notification.

I know that Whatsapp does that - even if Whatsapp app is close, when you are connected to the internet and you get a new messages or images, they saved the data to their local db.


React Native ~0.61.4 Event Emitter causing crash on IOS?

$
0
0

I am building a Music App where the mini player component holds the expo audio instance and it is separated from the bottom tab navigator for two important reasons :

1 - The audio instance lives in that mini-player component so navigation won't reset it.

2 - The mini player is global thus available in all application stack and tab navigations.

I am using NativeEventEmitter to help me control the player actions (ie: Play/Pause;Next; Pervious;) since those function lives in that mini-player component and needs to be called from a stack screen inside the tab navigator ! .

Now in Android it is working fine but in IOS, it is causing the application to crash.

The error :

Native Module cannot be null
- node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js:36:16 in App/Containers/Player/PlayerScreen.js:47:4 in _handleStop

The Logic I am implementing here , is upon clicking on the miniPlayer component after it is mounted, I am hiding it and navigating to the Player Screen;

Player Screen :

...
class PlayerScreen extends Component {
  constructor(props) {
    super(props);
    this.eventEmitter = new NativeEventEmitter();
    this._handleNext = this._handleNext.bind(this);
    this._handlePlayPause = this._handlePlayPause.bind(this);
    this._handlePrevious = this._handlePrevious.bind(this);
    this.state = {
      time: "00:00"
    };
  }

  componentDidMount() {

  }

  _handlePlayPause = () => {
    this.eventEmitter.emit("PLAYPAUSE", "");
  };

  _handleNext = () => {
    this.eventEmitter.emit("NEXTSONG", "");
  };

  _handlePrevious = () => {
    this.eventEmitter.emit("PREVIOUSSONG", "");
  };

  _handleStop = () => {
    this.eventEmitter.emit("STOPSONG", "");
  };
...
render()
....

MiniPlayer Component :

componentDidMount() {
    this.listener = DeviceEventEmitter.addListener("PLAYPAUSE", data => {
      this._handlePlayAndPause();
      console.log("New Event is registered At Listeners PLAY_PAUSE");

    });
    this.listenerN = DeviceEventEmitter.addListener("NEXTSONG", data => {
      this._handleNextSong()
      console.log("New Event is registered At Listeners NEXT_SONG ");

    });
    this.listenerP = DeviceEventEmitter.addListener("PREVIOUSSONG", data => {
     this._handlePreviousSong()
      console.log("New Event is registered At Listeners PREVIOUS_SONG");

    });

    this.listenerS = DeviceEventEmitter.addListener("STOPSONG", data => {
      this._handleStopSong();
      console.log("New Event is registered At Listeners STOPSONG");
    }) 

According the some article on Medium:

React Native no longer include the Node Standard Library. However, there are standalone modules which have reimplemented the EventEmitter API.

While looking at the NativeEventEmitter.js Abstract base class, I can see this at the constructor.

const EventEmitter = require('../vendor/emitter/EventEmitter');
const Platform = require('../Utilities/Platform');
const RCTDeviceEventEmitter = require('./RCTDeviceEventEmitter');

const invariant = require('invariant');

...

class NativeEventEmitter extends EventEmitter {
  _nativeModule: ?NativeModule;

  constructor(nativeModule: ?NativeModule) {
    super(RCTDeviceEventEmitter.sharedSubscriber);
    if (Platform.OS === 'ios') {
      invariant(nativeModule, 'Native module cannot be null.'); <== This where it crashes
      this._nativeModule = nativeModule;
    }
  }

Update :

I have created a snack with two component that reproduce what I am trying to achieve :

https://snack.expo.io/@git/github.com/oflarcade/customEventsExpo

on Android it is working fine / on IOS :

enter image description here

Unable to read package larger than 184 bytes on iOS using react native BLE PLX

$
0
0

I'm trying to read a characteristic that sends a JSON string as the value, this string is larger than 185 bytes, which is not a problem when testing it on an Android device but it's being cut off when I read it in iOS.

Steps to Reproduce

  1. Scan for devices.
  2. connect to device
  3. Discover all services and characteristics for device.
  4. send write characteristic with response for device logging into the device with a username and password.
  5. send a read characteristic for device (both read and write use the same service and characteristic).
  6. when I read the value, it's cut off and repeated 3 times.

the correct response that I get with Android:

Base 64:

eyJqc29ucnBjIjoiMi4wIiwicmVzdWx0IjpbMCx7InVidXNfcnBjX3Nlc3Npb24iOiJ4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eCIsInRpbWVvdXQiOjMwMCwiZXhwaXJlcyI6Mjk5LCJhY2xzIjp7ImFjY2Vzcy1ncm91cCI6eyJ4eHh4eC11c2VyIjpbInJlYWQiLCJ3cml0ZSJdfSwidWJ1cyI6eyJmd21hbiI6WyIqIl0sInh4eHh4LmFjcyI6WyJyZWJ1aWxkX3h4eHhfcHJvZmlsZXMiXSwieHh4eHguYXBwIjpbIioiXSwibmV0d29yayI6WyJyZWxvYWQiXSwibmV0d29yay5pbnRlcmZhY2UueHh4IjpbInN0YXR1cyJdLCJuZXR3b3JrLmludGVyZmFjZS54eHgiOlsic3RhdHVzIl0sInVjaSI6WyIqIl19LCJ1Y2kiOnsiKiI6WyJyZWFkIiwid3JpdGUiXX19LCJkYXRhIjp7InVzZXJuYW1lIjoieHh4eHgifX1dLCJpZCI6MX0=

JSON string:

{"jsonrpc":"2.0","result":[0,{"ubus_rpc_session":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","timeout":300,"expires":299,"acls":{"access-group":{"xxxxx-user":["read","write"]},"ubus":{"fwman":["*"],"xxxxx.acs":["rebuild_xxxx_profiles"],"xxxxx.app":["*"],"network":["reload"],"network.interface.xxx":["status"],"network.interface.xxx":["status"],"uci":["*"]},"uci":{"*":["read","write"]}},"data":{"username":"xxxxx"}}],"id":1}

the response that I get with iOS:

Base 64:

eyJqc29ucnBjIjoiMi4wIiwicmVzdWx0IjpbMCx7InVidXNfcnBjX3Nlc3Npb24iOiJ4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eCIsInRpbWVvdXQiOjMwMCwiZXhwaXJlcyI6Mjk5LCJhY2xzIjp7ImFjY2Vzcy1ncm91cCI6eyJ4eHh4eC11c2VyIjpbInJlYWQiLCJ3cml0ZSJdfSwidWJ1cyI6eyJmd21hbiI6W3sianNvbnJwYyI6IjIuMCIsInJlc3VsdCI6WzAseyJ1YnVzX3JwY19zZXNzaW9uIjoieHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHgiLCJ0aW1lb3V0IjozMDAsImV4cGlyZXMiOjI5OSwiYWNscyI6eyJhY2Nlc3MtZ3JvdXAiOnsieHh4eHgtdXNlciI6WyJyZWFkIiwid3JpdGUiXX0sInVidXMiOnsiZndtYW4iOlt7Impzb25ycGMiOiIyLjAiLCJyZXN1bHQiOlswLHsidWJ1c19ycGNfc2Vzc2lvbiI6Inh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4IiwidGltZW91dCI6MzAwLCJleHBpcmVzIjoyOTksImFjbHMiOnsiYWNjZXNzLWdyb3VwIjp7Inh4eHh4LXVzZXIiOlsicmVhZCIsIndyaXRlIl19LCJ1YnVzIjp7ImZ3bWFuIjpb

JSON string:

{"jsonrpc":"2.0","result":[0,{"ubus_rpc_session":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","timeout":300,"expires":299,"acls":{"access-group":{"xxxxx-user":["read","write"]},"ubus":{"fwman":[{"jsonrpc":"2.0","result":[0,{"ubus_rpc_session":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","timeout":300,"expires":299,"acls":{"access-group":{"xxxxx-user":["read","write"]},"ubus":{"fwman":[{"jsonrpc":"2.0","result":[0,{"ubus_rpc_session":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","timeout":300,"expires":299,"acls":{"access-group":{"xxxxx-user":["read","write"]},"ubus":{"fwman":[

  • Library version: react-native-BLE-PLX v.1.1.0
  • Platform: iOS 11.4.1.
  • Platform logs XCode:
[RxBLEKit|VERB|15:55:51.878]: CentralManager(7522903616) didDiscover(peripheral: Peripheral(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, name: Optional("BlueZ 5.49")),
rssi: -53)
[RxBLEKit|DEBG|15:55:52.126]: CentralManager(7522903616) stopScan()
[RxBLEKit|DEBG|15:55:52.128]: CentralManager(7522903616) retrievePeripherals(
withIdentifiers: [A0AA0000-000A-00AA-AAAA-AA000AA00A00])
[RxBLEKit|DEBG|15:55:52.137]: CentralManager(7522903616) connect(
peripheral: Peripheral(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, name: Optional("BlueZ 5.49")),
options: nil)
[RxBLEKit|DEBG|15:55:53.288]: Peripheral(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, name: Optional("BlueZ 5.49")) discoverServices(
serviceUUIDs: nil)
[RxBLEKit|DEBG|15:55:53.925]: Peripheral(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, name: Optional("BlueZ 5.49")) didDiscoverServices(services
: Optional("[Service(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, id: 7520873408)]"),
error: nil)
[RxBLEKit|DEBG|15:55:53.928]: Peripheral(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, name: Optional("BlueZ 5.49")) discoverCharacteristics(
characteristicUUIDs: nil,
for: Service(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, id: 7520873408))
[RxBLEKit|DEBG|15:55:53.985]: Peripheral(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, name: Optional("BlueZ 5.49")) didDiscoverCharacteristicsFor(for:
Service(uuid: B5DF559F-F530-4661-84C6-F3B9D5F76985, id: 7520873408), characteristics:
Optional("[Characteristic(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, id: 7584057696)]"),
error: nil)
[RxBLEKit|DEBG|15:55:53.987]: Peripheral(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, name: Optional("BlueZ 5.49")) discoverDescriptors(
for: Characteristic(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, id: 7584057696))
[RxBLEKit|DEBG|15:55:53.992]: Peripheral(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, name: Optional("BlueZ 5.49")) didDiscoverDescriptorsFor
(for:Characteristic(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, id: 7584057696), descriptors:
Optional("[]"),
error: nil)
[RxBLEKit|DEBG|15:55:54.570]: Peripheral(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, name: Optional("BlueZ 5.49")) writeValue(
data: 7b226a736f6e727063223a22322e30222c226964223a312c226d6574686f64223a2263616c6c222c22706172616d73223a5b223030303030303030303030303030303030303030303030303030303030303030222c2273657373696f6e222c226c6f67696e222c7b22757365726e616d65223a227878787878222c2270617373776f7264223a22303030303030227d5d7d,
for: Characteristic(uuid:A0AA0000-000A-00AA-AAAA-AA000AA00A00, id: 7584057696),
type: withResponse)
[RxBLEKit|DEBG|15:55:54.644]: Peripheral(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, name: Optional("BlueZ 5.49")) didWriteValueFor(for:Characteristic(uuid:A0AA0000-000A-00AA-AAAA-AA000AA00A00, id: 7584057696),
value: nil,
error: nil)
[RxBLEKit|DEBG|15:55:54.661]: Peripheral(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, name: Optional("BlueZ 5.49")) readValue(
for: Characteristic(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, id: 7584057696))
[RxBLEKit|DEBG|15:55:54.889]: Peripheral(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, name: Optional("BlueZ 5.49")) didUpdateValueFor(for:Characteristic(uuid: A0AA0000-000A-00AA-AAAA-AA000AA00A00, id: 7584057696),
value: Optional("227b6a736f6e727063223a22322e30222c22726573756c74223a5b302c7b22756275735f7270635f73657373696f6e223a227878787878787878787878787878787878787878787878787878787878787878222c2274696d656f7574223a3330302c2265787069726573223a3239392c2261636c73223a7b226163636573732d67726f7570223a7b2278787878782d75736572223a5b2272656164222c227772697465225d7d2c2275627573223a7b2266776d616e223a5b7b226a736f6e727063223a22322e30222c22726573756c74223a5b302c7b22756275735f7270635f73657373696f6e223a227878787878787878787878787878787878787878787878787878787878787878222c2274696d656f7574223a3330302c2265787069726573223a3239392c2261636c73223a7b226163636573732d67726f7570223a7b2278787878782d75736572223a5b2272656164222c227772697465225d7d2c2275627573223a7b2266776d616e223a5b7b226a736f6e727063223a22322e30222c22726573756c74223a5b302c7b22756275735f7270635f73657373696f6e223a227878787878787878787878787878787878787878787878787878787878787878222c2274696d656f7574223a3330302c2265787069726573223a3239392c2261636c73223a7b226163636573732d67726f7570223a7b2278787878782d75736572223a5b2272656164222c227772697465225d7d2c2275627573223a7b2266776d616e223a5b"),
error: nil)
  • Sample code:
  const bluetooth = () => {
    const deviceUUID =
      Platform.OS === 'ios'
        ? 'A0AA0000-000A-00AA-AAAA-AA000AA00A00'
        : 'A0:00:0A:00:A0:00'
    manager.startDeviceScan(null, null, async (error, device) => {
      if (error) {
        console.error(error)
        manager.cancelDeviceConnection(deviceUUID)
      }
      console.log(device)
      if (device && device.localName === 'Device XX-00') {
        const jsonDataServiceUUID = 'A0AA0000-000A-00AA-AAAA-AA000AA00A00'

        const jsonFormattedCharacteristicUUID =
          'A0AA0000-000A-00AA-AAAA-AA000AA00A00'

        manager.stopDeviceScan()
        await manager.connectToDevice(deviceUUID)

        await manager.discoverAllServicesAndCharacteristicsForDevice(deviceUUID)
        let write
        try {
          write = await manager.writeCharacteristicWithResponseForDevice(
            deviceUUID,
            jsonDataServiceUUID,
            jsonFormattedCharacteristicUUID,
            Buffer.from(
              JSON.stringify({
                jsonrpc: '2.0',
                id: 1,
                method: 'call',
                params: [
                  '00000000000000000000000000000000',
                  'session',
                  'login',
                  {
                    username: 'xxxxx',
                    password: '000000',
                  },
                ],
              }),
            ).toString('base64'),
          )
        } catch (err) {
          console.error(err)
        }
        console.log({ write })

        const read = await manager.readCharacteristicForDevice(
          deviceUUID,
          jsonDataServiceUUID,
          jsonFormattedCharacteristicUUID,
        )
        if (read.value) {
          console.log(read)
          const responseJson = Buffer.from(read.value, 'base64').toString()
          console.log(responseJson)
        }
      }
    })
  }
  bluetooth()

React Native Press Two Buttons at the same time

$
0
0

Goal

I need users to be able to press up to 4 buttons at the same time in React Native.

Current Roadblock

I'm using TouchableHighlight and when one button is pressed, none of the other 3 buttons can be pressed by the user.

Code

This is the function I'm using to display each of the 4 coloured quadrants you see below. If including more code will be helpful, just let me know!

    return (
      <TouchableOpacity
        style={[styles.button, styles[color]]}
        onPress={() => {
          EventRegister.emit('firstPressed', color);
          EventRegister.removeEventListener(this.listener);
          this.setState({[color]: true});
        }}
        disabled={this.state[color]}></TouchableOpacity>
    );
  };

Screenshot

This is a screenshot of the app where once the countdown clock gets to zero, 4 players race to push each button as quickly as they can (it's an iPad app so they have a large playing surface). Each player needs to receive feedback from their touch or they will think they lost because the app didn't recognize their input.

ScreenShot

how can send badge from firebase-admin to android application?

$
0
0

I want to send badge from firebase-admin to applications. I can send badge to iOS apps and show its on app icon but in android can not. how can send badge from firebase-admin to android applications and show its on app icon?

How to profile network on React-Native?

$
0
0

I am searching that for a day but can't get proper solution.

I have to know how to profile network requests on my react-native app.

I am uploading data to the API and two servers and want to know what is the size of uploaded data. How can I track that.

I tried Android Studio Network Profiler but I think it misses some request parts and there is an IOS side of application. Any advice?

Thanks in advance

Viewing all 16553 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>