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

How to return a message from a method in Swift to Objective-c

$
0
0

I have a class in Swift that is instantiated in objective-c. This class has a method that has an implementation of a payment framework, how can I return an error or success message?

Swift class

@objcclass SwOpenpay: NSObject {@objcfunc run() ->NSString {  openpay = Openpay(withMerchantId: "", andApiKey: "", isProductionMode: false, isDebug: false)  let card = TokenizeCardRequest(cardNumber: "4111111111111111", holderName: "John Doe", expirationYear: "27", expirationMonth: "10", cvv2: "111")  openpay.tokenizeCard(card: card) { (OPToken) in    return "Success"  } failureFunction: { (NSError) in    return "Error"  }}

The above says: Cannot convert value of type 'String' to closure result type '()'

The method call in Objective-c I do it like this:

@implementation RCTOpenpayModuleRCT_EXPORT_MODULE();RCT_EXPORT_METHOD(createCreditCard:(RCTPromiseResolveBlock)resolve                  rejecter:(RCTPromiseRejectBlock)reject) {  SwOpenpay * obj = [[SwOpenpay alloc] init];  NSString * test = [obj run];  resolve(test);}@end

How can I return the success or failure error to send in the resolve of my promise?


react native splash screen programatically

$
0
0

I want to manage splash screen programatically in react native. Is there any way get splash screen image from api or internal storage. Also I want to change app name and app icon programmatically. For example after change picker item change app can be change splash screen, app name and icon.

React-native Modal Child elements not clickable in IOS 14.3 iphone 12

$
0
0

My buttons inside modal is not clickable in iphone 12. it works fine in iphone 12 below models.Can any one help ?

This is working fine in Android as well as other ios models like iphone 6 , 7 , 8, 10 ,11 but not in iphone 12. When i click button modal will not dismiss. Even entire screen is not clickable.

import {Button, Card, Container, Title} from 'native-base';import React, {useState} from 'react';import {SafeAreaView, Text, View} from 'react-native';import Modal from 'react-native-modal';export const ModalTesterView = () => {  const [isModalVisible, setModalVisible] = useState(false);  const toggleModal = () => {    setModalVisible(!isModalVisible);  };  return (<SafeAreaView><View><Title> Hello</Title><Button bordered onPress={toggleModal}><Text>Show</Text></Button></View><Modal        isVisible={isModalVisible}        accessibilityViewIsModal={true}        animationIn="zoomInUp"        animationOut="zoomOut"><Card><View style={{height: 250, backgroundColor: '#FFF'}}><Text>Hello!</Text><Button bordered onPress={toggleModal}><Text>Close</Text></Button></View></Card></Modal></SafeAreaView>  );};

Is it possible to create a floating widget/button with react-native

$
0
0

I have seen a lot of mobile apps that come with a floating button/widget when you exit the app to do certain features like recording the screen and stuff like this. I haven't seen a way to implement this is react-native until now. Is it possible?

I am not talking about a floating action button here.

Apple rejects my app because of using both AdsConsent and AppTrackingTransparency

$
0
0

I've just got this message from apple

We noticed your app includes App Tracking Transparency permissions requests, but it encourages or directs users to accept tracking. Specifically, your app directs the user to accept tracking in the following way(s):

  • A message asks users to reconsider their decision after they deny permission

I think the issue comes from where I call both AdsConstent and AppTrackingTransparency on the first lunch of the app.

Should I call the consent form(AdsConsent.showForm) on ios if I add AppTrackingTransparency?

React Native 0.64 won't build iOS app after updating Xcode to 12.5 and iOS to 14.5

$
0
0

After upgrading Xcode to 12.5 and iOS to 14.5, I can't run the iOS app on a real device nor in the simulator.

After running npm run ios, I get this message:

The following build commands failed:        CompileC .../Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Flipper-Folly.build/Objects-normal/x86_64/DistributedMutex.o /Users/guilherme/Documents/Dood/ios/Pods/Flipper-Folly/folly/synchronization/DistributedMutex.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler

If I try to run the app on a real device using Xcode, this is the error I get (related to Flipper-Folly):

.../ios/Pods/Headers/Private/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h:1051:5: 'atomic_notify_one<unsigned long>' is unavailable

Ideas? Thanks!

UPDATE:

React native has been updated to 0.64.1. You can now just change your react-native dependency to this version within your package.json file, then run npm install

Virtual keyboard is not visible on iOS React Native

$
0
0

I'm working on a React Native app that can scan barcodes using the phone's camera or an infrared scanner connected via bluetooth.

This is the scanner: https://www.scopelink.com.au/wp-content/uploads/2020/07/Urovo-R70-R71-User-Manual.pdf

On Android it works perfectly but on iOS (iPhone) when I connect to the scanner, the virtual keyboard no longer appears, from what I understand the phone sees the scanner as an external keyboard. I tried to find a combination of scanner buttons to make the keyboard appear on the phone (I searched and saw that some have this option) but I did not find anything.

Can someone help me? Thank you!

React Native Push Notification onRegister token is null

$
0
0

I am using zo0r react-native-push-notification library.

For some reason, when i open the app for the first time after i installed it on the mobile device (iOS or Android) the token is returned as null.

    PushNotification.configure({onRegister: function(token) {    console.log( 'TOKEN:', token );},onNotification: function(notification) {    console.log( 'NOTIFICATION:', notification );},senderID: "YOUR GCM SENDER ID",permissions: {    alert: true,    badge: true,    sound: true},popInitialNotification: true,requestPermissions: true, });

My question is, which is the best approach to get the token if the onRegister method returns token as null?Do i have to recall this function in other screen of the app?

"react": "16.0.0-alpha.6","react-native": "^0.44.3","react-native-push-notification": "^3.0.1"

Thank you for your help,

Mikhi


Custom Button Design "Sign in with Apple" in React-native

$
0
0

I want to add "Sign in with Apple" functionality in my React-native application. I have search and googled it but not able to customise my Apple Button But forcing to use default apple button. How can I achieve this if it is possible. I want this Design.

enter image description here

I am facing the below issues is anyone knows how to resolve these issues

$
0
0

0

I am facing the below issues is anyone knows how to resolve these issues.

2021-05-25 20:56:29.185461+0530 Inspector[17230:5714645] [BackgroundTask] Background task still not ended after expiration handlers were called: <UIBackgroundTaskInfo: 0x2835d2500>: taskID = 89, taskName = Called by myApp, from -[AppDelegate applicationDidEnterBackground:], creationTime = 584536 (elapsed = 64). This app will likely be terminated by the system. Call UIApplication.endBackgroundTask(:) to avoid this.

Build input file cannot be found

$
0
0

CopySwiftLibs /Users/macbookpro/Library/Developer/Xcode/DerivedData/beeapp-cpbklzhsycxubxegrkeglncegmlr/Build/Products/Debug-iphonesimulator/beeapp.app (in target 'beeapp' from project 'beeapp')cd /Users/macbookpro/Documents/react-native/VirtualMusic/iosexport CODESIGN_ALLOCATE=/Users/macbookpro/Desktop/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocateexport DEVELOPER_DIR=/Users/macbookpro/Desktop/Xcode.app/Contents/Developerexport SDKROOT=/Users/macbookpro/Desktop/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.6.sdkbuiltin-swiftStdLibTool --copy --verbose --sign - --scan-executable /Users/macbookpro/Library/Developer/Xcode/DerivedData/beeapp-cpbklzhsycxubxegrkeglncegmlr/Build/Products/Debug-iphonesimulator/beeapp.app/beeapp --scan-folder /Users/macbookpro/Library/Developer/Xcode/DerivedData/beeapp-cpbklzhsycxubxegrkeglncegmlr/Build/Products/Debug-iphonesimulator/beeapp.app/Frameworks --scan-folder /Users/macbookpro/Library/Developer/Xcode/DerivedData/beeapp-cpbklzhsycxubxegrkeglncegmlr/Build/Products/Debug-iphonesimulator/beeapp.app/PlugIns --platform iphonesimulator --toolchain /Users/macbookpro/Desktop/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain --destination /Users/macbookpro/Library/Developer/Xcode/DerivedData/beeapp-cpbklzhsycxubxegrkeglncegmlr/Build/Products/Debug-iphonesimulator/beeapp.app/Frameworks --strip-bitcode --strip-bitcode-tool /Users/macbookpro/Desktop/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip --emit-dependency-info /Users/macbookpro/Library/Developer/Xcode/DerivedData/beeapp-cpbklzhsycxubxegrkeglncegmlr/Build/Intermediates.noindex/beeapp.build/Debug-iphonesimulator/beeapp.build/SwiftStdLibToolInputDependencies.dep

error: Build input file cannot be found: '/Users/macbookpro/Library/Developer/Xcode/DerivedData/beeapp-cpbklzhsycxubxegrkeglncegmlr/Build/Products/Debug-iphonesimulator/beeapp.app/beeapp' (in target 'beeapp' from project 'beeapp')

React Native: Determine number of lines of Text component

$
0
0

As the title says, I've been trying to find a way to determine the number of lines the text component AFTER it has been given text. Look at my example below.

<Text>    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi semper ut ipsum in ultrices. Vivamus fringilla lacinia odio in accumsan. Proin sit amet pellentesque tortor. Nam mollis sit amet ligula id convallis. Etiam in semper diam. Cras id elit consectetur, interdum ante id, tincidunt nisi. Integer non elit placerat, dignissim nibh at, faucibus sem. Curabitur nec posuere turpis. Vivamus rhoncus nulla vitae mi imperdiet, elementum eleifend mi laoreet. Vestibulum molestie turpis non nibh elementum, sed ornare magna tristique. Aliquam erat volutpat. Phasellus volutpat mi vel tempor finibus.</Text>

At runtime, how can I determine how many lines this Text component has rendered. This number will vary depending on device (eg. iPhone 5 will need to render more lines vs iPhone 6+ as it has a smaller screen size). I've checked the source code for the Text component but there doesn't seem to be anything I'm looking for.

I am using React Native 0.24.

Any ideas?

Cheers.

React Native iOS native module pass parameters

$
0
0

I am writing an NPM library that contains iOS & Android native modules. Important is that I need to pass parameters to the native module before startup. This works great for Android:

package ...import com.facebook.react.bridge.*class MyNativeModule(reactContext: ReactApplicationContext, parameter: String) {    override fun getName(): String {        return "MyModule"    }    @ReactMethod    fun retrieveParameter(promise: Promise) {        promise.resolve(parameter)    }}

When turning off autolinking a library user can just create their own RN package and use the following to set the parameter:

class MyAppRNPackage(private val voizeCore: VoizeCore = VoizeCore.getInstance()) : ReactPackage {    override fun createNativeModules(reactApplicationContext: ReactApplicationContext): List<NativeModule> {        return arrayListOf<NativeModule>(            MyNativeModule(reactApplicationContext, "this is the parameter"),        )    }    override fun createViewManagers(reactApplicationContext: ReactApplicationContext): List<ViewManager<*, *>> {        return emptyList()    }}

In iOS the native module would look something like this:

// MyNativeModule.m#import "MyNativeModule.h"@implementation MyNativeModuleRCT_EXPORT_MODULE();RCT_EXPORT_METHOD(retrieveParameter:(RCTPromiseResolveBlock)resolve rejecter: (RCTPromiseRejectBlock)reject){    resolve(???)}@end

But how is it possible to set a parameter for the iOS module? The problem is that in iOS, native modules can not be registered manually. Furthermore, only classes are registered not class instances.

Any idea how you could pass parameters from native code to the iOS native module?

Display PDF in React Native using Forms Field value not showing on IOS

$
0
0

Im trying to create a viewer on our app using the react-native-pdf and tried react-native-view-pdf but i have problems with the PDF Forms field on IOS the values/data aren't showing. But when the field is focused/tapped it will show the value/data. on Android the Forms field data is showing as expected. Image on IOS shown below:

IOS PDF first load

IOS PDF Field tapped/focused

Using react-native-pdf:

<View style={{ flex: 1 }}><Pdf        minScale={1.0}        maxScale={1.0}        scale={1.0}        spacing={0}        fitPolicy={2}        enablePaging={true}     // onTouchStart={(e) => {     //     console.log('touchMove', e.nativeEvent);     //     if (this.state.pdfEditMode) {     //         this.setState({ showDraggrable: false, cxValue: e.nativeEvent.locationX, cyValue: e.nativeEvent.locationY, xValue: e.nativeEvent.locationX, yValue: e.nativeEvent.locationY }, () => {     //             setTimeout(() => {     //                 this.setState({ showDraggrable: true, })     //             }, 0)     //         })     //     }     // }}        usePDFKit={false}        source={{ uri: `data:application/pdf;base64,${this.state.pdfBase64}` }}        onLoadComplete={(numberOfPages, filePath, { width, height }) => { this.setPageWH(width, height) }}        onPageChanged={(page, numberOfPages) => {            console.log(`current page: ${page}`);            this.setState({ pageNumber: page });        }}        onError={(error) => {            console.log(error);        }}        onPressLink={(uri) => {            console.log(`Link presse: ${uri}`)        }}       // onPageSingleTap={(page, x, y) => {       //     console.log(x, y)       //     this.handleSingleTap(page, x, y);       // }}         style={styles.pdf}/> </View>

Using react-native-view-pdf

<View style={{ flex: 1}}>     <PDFView        fadeInDuration={250.0}        style={styles.pdf}        resource={this.state.pdfBase64}        resourceType={'base64'}        onLoad={() => console.log(`PDF rendered from base64}`)}        onError={(error) => console.log('Cannot render PDF', error)}/> </View>

Libraries Version:

"react": "16.6.3","react-native": "0.58.1","react-native-pdf": "^5.1.7","react-native-view-pdf": "^0.11.0",

React native image resizing crops the image

$
0
0

I'm just getting started with react native. There's an image I want to resize but adding width and height acts like image cropping.this is how it looks

Here's the code,

const App = () => {  return (<SafeAreaView><View><Text>Hello world!</Text><Image          source={require('./assets/logos/logo.png')}          style={styles.logo}        /></View></SafeAreaView>  );};const styles = StyleSheet.create({  sectionContainer: {    marginTop: 32,    paddingHorizontal: 24,  },  logo: {    height: 50,  },  highlight: {    fontWeight: '700',  },});

React Native Drag and Drop Into folder

$
0
0

on iPhone's when you long press onto an app icon you can drag it onto another app icon and iOS will open a new popup that you can create a "folder" that contains them, I dont remember if the Android is capable to do that so I'm talking about iPhones only.

What i wonder is if this is possible with react native, which probably is but i couldn't find anything helpful and also im having hard times what am i supposed to search exactly.

Hope you can give me an idea, a npm package or a tutorial so i can give it a try.

Thanks.

Header component height issue in iOS React Native

$
0
0

I'm using React Native and iOS simulator, but I can't make the Header works properly. I need the Header to go to the top of the screen. I'm using react navigator btw.

Need help please.

Thank you

Header ScreenShot

Style:

import styled from 'styled-components/native';import { Platform, StatusBar } from 'react-native';export const Container = styled.View`  padding: 0 16px;  padding-top: ${Platform.OS === 'android' ? StatusBar.currentHeight : 0}px;  width: 100%;  height: ${64 + (Platform.OS === 'android' ? StatusBar.currentHeight : 0)}px;  background-color: white;  flex-direction: row;  justify-content: space-between;  align-items: center;`;export const Logo = styled.Image`  width: 143px;  height: 31px;`;export const SearchIcon = styled.Image`  width: 32px;  height: 32px;`;

How to migrate to Xcode 12.5

$
0
0

I'm not able to build a React Native project, which built correctly using Xcode 11, using Xcode 12.5.

I can no longer use Xcode 11 because only more current versions of Xcode carry the necessary API to publish/upload to TestFlight and the app store.

Now I get three build errors:

Cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an rvalue of type 'NSArray<Class> *'Cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an rvalue of type 'NSArray<Class> *'Cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an rvalue of type 'NSArray<Class> *'

I also noticed that deployment targets were automatically upgraded from 10 and 9:

- IPHONEOS_DEPLOYMENT_TARGET = 9.0;+ IPHONEOS_DEPLOYMENT_TARGET = 12.1;

Some new properties were added related to Clang:

+ CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;

How can I configure the project to deploy this app using Xcode 12.5?

$ react-native infoinfo Fetching system and libraries information...System:OS: macOS 11.3CPU: (4) x64 Intel(R) Core(TM) i3-8100B CPU @ 3.60GHzMemory: 256.45 MB / 8.00 GBShell: 3.2.57 - /bin/bashBinaries:Node: 10.16.0 - /usr/local/bin/nodeYarn: 1.21.1 - ~/npm-global/bin/yarnnpm: 6.9.0 - /usr/local/bin/npmWatchman: 4.9.0 - /usr/local/bin/watchmanSDKs:iOS SDK:Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4IDEs:Xcode: 12.5/12E262 - /usr/bin/xcodebuildnpmPackages:react: ^16.11.0 => 16.12.0react-native: 0.61.4 => 0.61.4npmGlobalPackages:react-native-cli: 2.0.1

Unable to integrate "Black Berry Dynamics" in React-Native (iOS)

$
0
0

I followed these steps to integrate :-

https://github.com/blackberry/BlackBerry-Dynamics-React-Native-SDK/blob/master/modules/BlackBerry-Dynamics-for-React-Native-Base/README.md#blackberry-dynamics-sdk-for-ios

and then in package.json ->

dependency {   "BlackBerry-Dynamics-for-React-Native-Base": "file:../../node_modules/BlackBerry-Dynamics-React-Native-SDK/modules/BlackBerry-Dynamics-for-React-Native-Base"}

While building the react-native iOS app I am getting this issue :-

error Could not find the following native modules: BbdRNBase. Did you forget to run "pod install" ?

Once I moved to my iOS folder and run pod install I am facing issue like :-

[!] Unable to find a specification for `BlackBerryDynamics` depended upon by `BbdRNBase`You have either: * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`. * mistyped the name or version. * not added the source repo that hosts the Podspec to your Podfile.

My react-version is 0.64Xcode version is :- 12.1

Javascript / Native code out of sync (differing number of arguments) error

$
0
0

I have recently updated to ReactNativeControllers 2.03 from 1.24. I have also updated RN to 0.25. I am using a fork which only adds a Podspec file. After sorting out all the import changes in RN I am now stumped on this error:

(See also https://github.com/wix/react-native-controllers/issues/59)

RCCManager.setRootController was called with 3 arguments, but expects 2. If you haven't changed this method yourself, this usually means that your versions of the native code and JavaScript code are out of sync. Updating both should make this error go away.

The code in question:

In RCCManagerModule.m:

setRootController:(NSDictionary*)layout animationType:(NSString*)animationType globalProps:(NSDictionary*)globalProps)

and in index.js:

ControllerRegistry: {    registerController: function (appKey, getControllerFunc) {      _controllerRegistry[appKey] = getControllerFunc();    },    setRootController: function (appKey, animationType = 'none', passProps = {}) {      var controller = _controllerRegistry[appKey];      if (controller === undefined) return;      var layout = controller.render();      _validateDrawerProps(layout);      RCCManager.setRootController(layout, animationType, passProps);    }  },

As is evident, both have 3 parameters.

I've killed and restarted the packager. I've cleaned the Xcode project including derived data, and deleted watchman cache with watchman watch-del-all. I've deleted my node_modules folder, done npm install and pod install.

I've rebuilt the Xcode project. Still no luck. I don't know how to debug this further.

EDIT: I also tried to clean the pod cache, updated to Cocoapods 1.01...

I have a feeling there may be a red herring here somewhere. For reference my full trace looks like this:

2016-06-10 14:15:18.179 [warn][tid:com.facebook.React.JavaScript] Warning: ReactNative.Component is deprecated. Use React.Component from the "react" package instead.2016-06-10 14:15:18.239 JustTuner[7523:185768] Launching Couchbase Lite...2016-06-10 14:15:19.048 JustTuner[7523:185768] Couchbase Lite url = http://adamwilsonsMBP.lan:5984/2016-06-10 14:15:19.050 JustTuner[7523:185768] Launching Couchbase Lite...2016-06-10 14:15:19.058 JustTuner[7523:185768] Couchbase Lite url = http://adamwilsonsMBP.lan:5984/2016-06-10 14:15:19.538 [error][tid:main][RCTModuleMethod.m:456] RCCManager.setRootController was called with 3 arguments, but expects 2.                   If you haven't changed this method yourself, this usually means that                   your versions of the native code and JavaScript code are out of sync.                   Updating both should make this error go away.
Viewing all 16907 articles
Browse latest View live


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