I'm going through the docs in React Native and can only find navigating to external links from the app I am in.
I want to be able to navigate to the Settings app (more specifically to the privacy > location services page) but, can not seem to find the necessary information on it. There is the native iOS way of doing it which I am trying to replicate through React Native.
Is this possible?
I have tried the following to detect if there is a Settings URL. The console logs that the Settings url works however, it does not navigate to that page.
Update: thanks to #zvona I am now navigating to the settings page but not sure how to get to a specific deep link.
Linking.canOpenURL('app-settings:').then(supported => {
console.log(`Settings url works`)
Linking.openURL('app-settings:'
}).catch(error => {
console.log(`An error has occured: ${error}`)
})
You can access settings of the application with:
Linking.openURL('app-settings:');
But I don't know (yet) how to open a specific deep-link.
2021 update use:
Linking.openSettings();
otherwise your app will be rejected due use of non-public URL scheme
I successfully opened the settings by the code below, hope it's helpful :)
Linking.canOpenURL('app-settings:').then(supported => {
if (!supported) {
console.log('Can\'t handle settings url');
} else {
return Linking.openURL('app-settings:');
}
}).catch(err => console.error('An error occurred', err));
Reference: https://facebook.github.io/react-native//docs/linking.html
Since React Native version 0.59 this should be possible using openSettings();. This is described in the React Native Linking documentation. Although it did not work for me. When I tried quickly I saw a _reactNative.Linking.openSettings is not a function error message.
Linking.openSettings();
You can deep-link referencing the settings's index like so:
Linking.openURL('app-settings:{index}')
For example Linking.openURL('app-settings:{3}') would open the Bluetooth settings.
Linking.openURL('app-settings:1');
Adding an answer that worked for me and is easy to apply.
openSettings function in #react-native-community/react-native-permissions works for both iOS and Android.
Calling openSettings function will direct the user to the settings page of your app.
import { openSettings } from 'react-native-permissions';
openSettings();
You can import Linking from 'react-native' and then use Linking.openSettings() to trigger the call. This link explains it very concisely:
https://til.hashrocket.com/posts/eyegh79kqs-how-to-open-the-settings-app-in-reactnative-060
For example: to navigate under Settings/Bluetooth you have to use Linking.openURL('App-Prefs:Bluetooth');
For iOS 14 and ReactNative 16.13
You can use the most easiest way to open the app setting from react-native.
just,
import { Linking } from 'react-native';
and user below line anywhere you want open the app setting.
Linking.openSettings();
Old question, but this didn't work for me on Android and I found something that did. Hope this helps anyone looking for the same. :)
https://github.com/lunarmayor/react-native-open-settings
I don't have the ability to test it for iOS though.
Opens the platform specific settings for the given application.
You can handle your case using Linking from react-native. In my case, I accessed the touch id settings on IOS using:-
Linking.openURL('App-Prefs:PASSCODE');
Related
We have App in ios. It was developed in unity. Yesterday apple informed that our app has been rejected because we have been used advertising in your app. But we did not used any advertisements in our app. This is the screen shot.
we have been searching in google. but we have not found any solutions. So any idea how to remove the Isadvertisingtrackingenabled in unity.
strong textThose who have received the above error. I have followed the below steps and our app got approved.
The answer is taken from this forum
https://forum.unity.com/threads/important-changes-for-ios-kids-apps-action-needed-by-developers.838939/.
all the credit goes to that person only. I am just posting for information purpose only.
To make the manual fix, please follow the instructions below:
Open the file DeviceSettings.mm within your Xcode project.
Find and remove the line #include
Find and completely remove the function “QueryASIdentifierManager”
Find the function “UnityAdvertisingIdentifier” and replace it with:
extern "C" const char* UnityAdvertisingIdentifier()
{
return NULL;
}
UnityAdvertisingTrackingEnabled()
find the unityadvertisingtrackingenabled and replace the code.
extern "C" int UnityAdvertisingTrackingEnabled()
{
return 0;
}
NOTE:
In Package manager . Unity Ads and Unity Analytics are enabled as default. So kindly disable the both. and then following the above steps. it will works fine for me.
after following the above steps mentioned by this above forum . you will receive one error. So to avoid the error.Kindly add
SystemConfiguration.framework.
in xcode FrameWork Path.
Then the error will solved and your app also got approved.
if you some one need any assistance i am ready to help you.
I'm creating an react-native app and I want to show and warning to user if their IOS version is < 11.0.
That works fine. I have something as follows:
What I want is to go the phone settings if they click on Go to settings.
The code for that is as follows:
Linking.canOpenURL('app-settings:').then(supported => {
if (!supported) {
console.log('Can\'t handle settings url');
} else {
return Linking.openURL('app-settings:');
}
}).catch(err => console.error('An error occurred', err));
Thus I try to do it with Linking.openURL('app-settings:'). But the problem is that that goes to the settings of my app, but I want to go to the settings index page or even better to system upgrade setting.
I need it only for IOS.
Any idea how can I do that?
You can no longer do that. You could use the URL App-Prefs:, which does what you want, but that will cause your app to be rejected upon review, because it's considered non-public URL scheme.
The only URL allowed by Apple is the constant UIApplicationOpenSettingsURLString, which takes you to your app's setting, not general settings of the device.
I have problem sharing a link on Facebook in my app made with Appcelerator
I’m using iOS 11 Simulator, Titanium SDK 7.1 and Facebook Module 5.8.
My tiapp.xml should be correct.
The facebook app is not installed on the simulator.
My code is:
var fb = require('facebook');
fb.initialize();
function shareLink() {
fb.addEventListener('shareCompleted', onShareCompleted);
fb.presentShareDialog({
link: "http://www.google.com"
});
}
function onShareCompleted(e){
fb.removeEventListener('shareCompleted', onShareCompleted);
if (e.success) Ti.API.info('Share request succeeded.');
else Ti.API.info('Failed to share.' + JSON.stringify(e));
}
When I try to share, the app show me a webpage of facebook with the error “The parameter ‘href’ or ‘media’ is required”.
If I switch the Facebook module from version 5.8 to 5.6, the first time I try to share, it fails, but the second time it work!
I can’t understand where I’m wrong.
Thanks for any help!
Try this. Its super easy and I always use it for social sharing:
https://github.com/ricardoalcocer/socialshare/tree/master/app/widgets/com.alcoapps.socialshare
I use Telerik-AppleWatch plugin for cordova.
i followed the instructions and i copied the simplified example from the project.
when i run the project the Built successfully but on the iwatch i see just the name of the app and blank screen.
I didn't receive error on the console.
i use xcode. target is- 8.2
There is not much information on the internet about it
function initAppleWatch() {
applewatch.init(function () {
alert("init");
onAppRequestsUpdate();
onGlanceRequestsUpdate();
});
applewatch.callback.onLoadAppMainRequest = onAppRequestsUpdate;
applewatch.callback.onLoadGlanceRequest = onGlanceRequestsUpdate;
}
can anybody know what can i do?
I work on it all week without success
thanks!:)
After following this tutorial I managed to integrate a Unity app into a native iOS app. The problem I'm currently facing is when I try to go back from the Unity part to native iOS.
For Android I solved this by doing something like:
public void ReturnToNative()
{
#if UNITY_ANDROID
AndroidJavaClass jc = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject> ("currentActivity");
jo.Call ("goBack");
#endif
#if UNITY_IOS
Application.Quit();
#endif
}
The native Java method "goBack" basically stops and then finishes an activity that contains the Unity part.
I know that for iOS the solution is not an Application.Quit(), I should use an iOS Plugin.
So my question is, what should this plugin do? How could I make it work?
I know how to create plugins, but I don't know what this particular plugin should contain.
Any help / hint / direction / comment is greatly appreciated!!
PS. I'm using Unity 5.4.2 and Xcode 8.0. The Unity part uses the Google Cardboard SDK.
For using native plugins on iOS read the following info:
https://docs.unity3d.com/Manual/NativePlugins.html
https://docs.unity3d.com/Manual/PluginsForIOS.html
It's been a couple of months since this question, but in case anyone else runs into a similar issue, here's how I managed to resolve this.