I want to know when a user screenshots while being in the app for analytics. for both Android and IOS.
How to detect when a user screenshots? (React Native, IOS and Android)
React native iOS library not found after updating
After I update an already existing React Native library, should i relink it again?.
ld: library not found for -lBranch-SDK
in addition,when I run react-native-link I get
react-native-branch ERR! Failed to add file to project
React-native camera roll linking issue
I am trying to add library to my project @react-native-community/cameraroll. But it is not getting linked and build always fails in Xcode, not even displaying error.
I am using React-native version 0.60
How do you execute Javascript in React-Native WebView?
I'm trying to execute javascript in a WebView that is loaded on an iOS advice. I'm trying to get a painfully simple example to work but it is consistently throwing an undefined or TypeError.
Here is the code:
import React, { Component } from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';
import { WebView } from 'react-native-webview';
export default class App extends Component {
constructor(props){
super(props)
this.onPressButton = this.onPressButton.bind(this)
}
onPressButton(){
this.webview.injectJavascript(`alert('hello')`)
}
render() {
return (
<View style={{ height: '100%' }}>
<WebView
ref={ref => (this.webview = ref)}
javaScriptEnabled={true}
source={{ uri: 'https://google.com' }}
/>
<Button onPress={this.onPressButton} style={{ height: '10%' }} title="Test Javascript" />
</View>
);
}
}
Please don't recommend to use injectedJavascript because that is not my desired functionality.
Would appreciate any other approaches as well.
React Native Notification IOS - APN Configuration
I have a problem with the configuration of push notification in IOS. I followed all the steps of the tutorial in the Invertase documentation (https://invertase.io/oss/react-native-firebase/v6/messaging/ios-configure-apns), but it didn't work. I read this article, and followed the steps up to the part of generating a development certificate (https://www.codementor.io/@uokesita/react-native-push-notifications-with-firebase-2019-10on0z19t6#generate-a-development-certificate). My JS code is as follows:
export default class App extends React.Component {
async componentDidMount() {
await messaging().registerForRemoteNotifications()
await messaging().requestPermission().then(async granted =>{
if (granted) {
console.log('User granted messaging permissions!');
if(Platform.OS === "ios"){
console.log("Token: " + await messaging().getToken())
}
} else {
console.log('User declined messaging permissions :(');
}
});
}
render() {
return (<AppContainer />)
}
}
Would anyone know to tell me why the notification does not want to appear? And when I request the Token as shown in the code below, the following error also appears:
[messaging/unknown] The operation couldn’t be completed. (com.firebase.iid error 1001.)
React Native - navigation.addListner is not an object
App.js:
import React, { Component } from 'react';
import {View,Text} from 'react-native';
import { createDrawerNavigator } from 'react-navigation-drawer';
import {createAppContainer} from 'react-navigation';
import Epics from './screens/tmp';
import Pager from './screens/Pager';
const DrawerNavigator = createDrawerNavigator({
Home: {screen: Epics},
Page: {screen: Pager}
},{initialRouteName: 'Home'});
const Stack = createAppContainer(DrawerNavigator);
export default class App extends Component {
render() {
return <Stack />;
}
}
Trying to invoke fetch API everytime a user lands on screen using navigation addListner event
componentDidMount() {
this.loadFeed(); // fetch API
const { navigation } = this.props;
this.focus = navigation.addListener('willFocus', () => {
this.loadFeed(); // fetch API
});
}
React Navigation version from package.json:
- "react-navigation": "^4.2.2"
- "react-navigation-drawer": "^2.4.2"
Is there a better way to detect an active screen on app and invoke the fetch API? Or fix for the given error below?
Type Error: undefined is not an object (evaluating 'navigation.addListner'):Error when the app launches
Periodically sending api request in the background and receiving the result as notification
I want to make an application exactly like the title. Every 5 or 15 minutes in the background, I will send a request to the api which I made and send a notification to my phone according to the results.
I used the react-native-notifications and react-native-background-timer plugin but when I lock my phone or close the app, notifications are not received. (IOS)
I struggled for a week, I couldn't do it. I'm waiting for your help.
React Native project cannot open real device (Can Not connect metro server 8081)
Hi I create proje yesterday always very nice but now simulator connected metro bundler but real device cannot connect and can not show home page just I see splash screen and not any error just white screen what can I do . React native always problem:(
Use https on dotnet core web api
I am currently implementing WEB APIs on dotnet core 3.1, which will be called by an ios app developed by react-native.
Apple requires secure connections.
I searched intensively on the web, but I was unable to find how to import the security certificate into my WEB API.
Can someone help me?
react native load app only if user is logged in calling AppRegistry.registerComponent multiple times
i have a user protected app, i want to authenticate user before loading the main app. so i was wondering is it possible to register more than one app and switch between them in runtime ?
for example i can have 3 apps 1. for login, 2. for admins, 3. for users
i register the three, and then run one of them based on condition,
AppRegistry.registerComponent('LoginApp',()=><LoginApp />);
AppRegistry.registerComponent('AdminApp',()=><AdminApp />);
AppRegistry.registerComponent('UserApp',()=><UserApp />);
i can see on https://facebook.github.io/react-native/docs/appregistry.html doc page many functions that seem useful, yet there is no documentation on how to use any of these functions :(
runApplication,unmountApplicationComponentAtRootTag seem like they can do what i want but how to implement this ?
RN fetch blob download docx or pdf from URL in IOS
What is done:
Implemented in Android and its getting downloaded in specific DCIM directory
in android.
In ios using DocumentDir
to download the pdf or docx file. Using "rn-fetch-blob": "^0.12.0"
;
Error:
In IOS it says the message in console :
The file saved to /var/mobile/Containers/Data/Application/E6FDC2DD-7FCA-44DC-85C4-A275078F8825/Documents/wow13.pdf
The code to download is something like this :
downloadFileOnSuccess = async () => {
let dirs =
Platform.OS == 'ios'
? RNFetchBlob.fs.dirs.DocumentDir
: RNFetchBlob.fs.dirs.DCIMDir;
console.log(dirs, 'document path');
RNFetchBlob.config({
// response data will be saved to this path if it has access right.
fileCache: true,
path: dirs + `/wow13.pdf`,
})
.fetch(
'GET',
'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf',
{
//some headers ..
},
)
.then(res => {
// the path should be dirs.DocumentDir + 'path-to-file.anything'
console.log('The file saved to ', res.path());
});
};
But i cannot get where the file is downloaded in my iphone 7 real device. Is there any permission i'm missing in IOS? Havent added any permission for IOS.
How to add an overlay on SFSafariViewController with react-navigation?
I'd like to show an overlay above the SFSafariViewController when I click on a link within SFSafariViewController.
An expected view is displayed below.
A similar issue has been posted in react-native-navigation. The solution is copied here:
// AppDelegate.m
[ReactNativeNavigation registerExternalComponent:@"RNNSafariViewController" callback:^UIViewController *(NSDictionary *props, RCTBridge *bridge) {
return [[RNNSafariViewController alloc] initWithProps:props];
}];
// RNNSafariViewController.m
#import "RNNSafariViewController.h"
@import SafariServices;
@implementation RNNSafariViewController {
NSURL* _url;
boolean* _readerMode;
}
- (instancetype)initWithProps:(NSDictionary *)props {
self = [super init];
_url = [[NSURL alloc] initWithString:props[@"url"]];
_readerMode = [props[@"readerMode"] boolValue];
return self;
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
SFSafariViewController *safariViewController = [[SFSafariViewController alloc] initWithURL:_url entersReaderIfAvailable:_readerMode];
safariViewController.delegate = self;
[self presentViewController:safariViewController animated:animated completion:nil];
}
@end
// RNNSafariViewController.h
#import <UIKit/UIKit.h>
@interface RNNSafariViewController : UIViewController<SFSafariViewControllerDelegate>
- (instancetype)initWithProps:(NSDictionary*)props;
@end
I would like to do the same in react-navigation. But I am not sure if react-navigation provides the same library RNNSafariViewController.h
as react-native-navigation does.
What would be a good way to implement this in react-navigation? Thanks!
How to change the iOS app display name programmatically in React native?
Actually, I want to change the App Icon and App display name dynamically in my iOS and Android React Native app. Here, I can change only the app icon in iOS and the app icon and app display name in Android by react-native-change-icon. Now I am facing problem in changing th e app name dynamically. Is there any way to change the App display name from React-Native for iOS. Thanks in advance.
React Native Mapbox - Can't build iOS app (MapboxMobileEvents issue)
When i try to build react native iOS app (via Fastlane) i get this error:
Debug: Command took 0 seconds
Debug: Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.1.sdk/usr/lib/libz.1.tbd
Debug: Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.1.sdk/usr/lib/libsqlite3.tbd
Debug: Search Path: "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/lib/darwin", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos", "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.1.sdk/usr/lib", "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.1.sdk/System/Library/Frameworks"
error: MapboxMobileEvents not found in dylib search path
Mapbox version: "@react-native-mapbox-gl/maps": "^7.2.0"
React Native version: "react-native": "0.61.5"
Any idea how to fix it?
How to set 'exclude_files' in Podfile rather than podspec
I've created a new react-native project (0.61.5) and am trying to install react-native-track-player. The default installation docs are pretty sparse but after going through the issues I was able to successfully get the app running, just in a hacky way.
The solution I needed is found in this thread. Setting s.exclude_files = ["ios/RNTrackPlayer/Vendor/AudioPlayer/Example"]
in node_modules/react-native-track-player/react-native-track-player.podspec
works but I don't want to add it again every time my node_modules folder gets reset.
I saw in a different thread (and ended up using this as well) that setting the swift version in the Podfile to 5 in the post_install
method will set the proper version of swift for react-native-track-player to work. I thought maybe I could move the exclude_files
hack from node_modules podspec file to my Podfile and solve all my problems, only it seems to not work when set there:
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['react-native-track-player'].include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '5'
config.build_settings['EXCLUDE_FILES'] = '../node_modules/react-native-track-player/ios/RNTrackPlayer/Vendor/AudioPlayer/Example`
end
end
end
end
TLDR: Is it possible to set exclude_files in my Podfile in the post_install call?
RN + Cocoapods = library not found for -lPods-XXX
I feel this question have been asked again and again but I swear I tested every solution seen on the internet and it's still happening.
Basically I moved my React Native project to using cocoapods. See my Podfile below. When I pod install I get added "libPods-XXX.a" to my "Link Binary With Librairies" build phase. I guess that's how Cocoapods works?
But when libPods-XXX.a is there I can't build, always get the error "library not found for -lPods-XXX". If I remove it manually it works fine. But then next pod install will add it.
What I tried already :
- I am using worskspace file
- "Build Active Architecture Only" is set to Yes in Debug, no in my other Schemes, for the XXX project and for every pods installed.
- "Other linker flags" in my target is set to "$(inherited)"
- "Library search path" in my target is set to "$(inherited)"
- Already tried to deintegrate and resinstall multiple times, same goes for node modules
I am really running out of ideas here. Can anyone point me to something else I might be missing?
Thanks
Podfile
platform :ios, '9.0'
target :XXX do
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
# Pods for XXX
pod 'react-native-signature-capture', :podspec => '../node_modules/react-native-signature-capture/react-native-signature-capture.podspec'
pod 'RNFS', :path => '../node_modules/react-native-fs'
pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
pod 'react-native-onesignal', :path => '../node_modules/react-native-onesignal'
pod 'RNI18n', :path => '../node_modules/react-native-i18n'
pod 'SentryReactNative', :path => '../node_modules/react-native-sentry'
pod 'react-native-version-number', :path => '../node_modules/react-native-version-number'
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
pod 'CodePush', :path => '../node_modules/react-native-code-push'
pod 'react-native-webview', :path => '../node_modules/react-native-webview'
pod 'react-native-background-upload', :path => '../node_modules/react-native-background-upload'
pod 'react-native-document-picker', :path => '../node_modules/react-native-document-picker'
pod 'RNImageCropPicker', :path => '../node_modules/react-native-image-crop-picker'
end
How to get app latest version from PlayStore/AppStore react native
I need to compare my app's version with the latest version from PlayStore/AppStore. I used react-native-version-check but it's not working properly for my app. Is there a way to call directly to the stores which will contain the version in the response? (using react native)
Can I upload an app with a different name in every country? on IOS and android
I have developed an app and would like to upload it on play store as well as on app store, is there an option to upload it as 1 APP but with a different name for every country?
ITMS-90809: Deprecated API Usage — Apple will stop accepting submissions of apps that use UIWebView APIs When upload my react native app
I tried to upload the app to the App Store, but there was a problem. I received an email telling me not to use UIWebView and was rejected.
ITMS-90809: Deprecated API Usage - Apple will stop accepting submissions of apps that use UIWebView APIs starting from April 2020 . See https://developer.apple.com/documentation/uikit/uiwebview for more information.
Upload one app to the app market, but how can it accommodate the different screen sizes?
I have built my react native to work for iPhone6. That is, the 'flex' values are geared for this phone. I want to upload this app to the app market, but there are so many different phones (iPhoneX, iPhone8 etc...). How do i release this app to the app market and cater for all these different screen sizes?
I know the different 'flex' values i need for each of the other phones, but how does the app market know which version with the right 'flex' is needed? I can't upload multiple versions of the app with different 'flex' values.