wumke / react-native-exit-app Goto Github PK
View Code? Open in Web Editor NEWExit,close,kill,shutdown app completely for React Native on iOS and Android.
License: MIT License
Exit,close,kill,shutdown app completely for React Native on iOS and Android.
License: MIT License
So, i'm using this on my project and i'm having this issue when building the App:
A problem occurred configuring project ':react-native-exit-app'.
> Could not resolve all artifacts for configuration ':react-native-exit-app:classpath'.
> Could not resolve com.android.tools.lint:lint-gradle-api:26.1.4.
Required by:
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4
> Could not resolve com.android.tools.lint:lint-gradle-api:26.1.4.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.4/lint-gradle-api-26.1.4.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.4/lint-gradle-api-26.1.4.pom'. Received status code 503 from server: Service Unavailable
> Could not resolve com.google.guava:guava:22.0.
Required by:
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:bundletool:0.1.0-alpha01
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > com.android.tools.build:gradle-api:3.1.4
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > com.android.databinding:compilerCommon:3.1.4
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > com.android.tools.build:builder:3.1.4 > com.android.tools:common:26.1.4
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > com.android.tools.build:builder:3.1.4 > com.android.tools.analytics-library:shared:26.1.4
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > com.android.tools.build:builder:3.1.4 > com.android.tools.analytics-library:tracker:26.1.4
> Skipped due to earlier error
> Could not resolve com.google.errorprone:error_prone_annotations:2.1.2.
Required by:
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:bundletool:0.1.0-alpha01
> Skipped due to earlier error
> Could not resolve org.ow2.asm:asm-tree:5.1.
Required by:
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > com.android.tools.build:builder:3.1.4
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > org.ow2.asm:asm-analysis:5.1
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > org.ow2.asm:asm-commons:5.1
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > org.ow2.asm:asm-util:5.1
> Skipped due to earlier error
> Could not resolve com.google.code.gson:gson:2.7.
Required by:
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > com.android.databinding:compilerCommon:3.1.4
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:bundletool:0.1.0-alpha01 > com.google.protobuf:protobuf-java-util:3.4.0
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > com.android.tools.build:builder:3.1.4 > com.android.tools:sdklib:26.1.4
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > com.android.tools.build:builder:3.1.4 > com.android.tools.build:manifest-merger:26.1.4
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > com.android.tools.build:builder:3.1.4 > com.android.tools.analytics-library:shared:26.1.4
> Skipped due to earlier error
> Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.2.0.
Required by:
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.0
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > com.android.tools.build:builder:3.1.4 > com.android.tools:sdk-common:26.1.4 > org.jetbrains.kotlin:kotlin-reflect:1.2.0
> Skipped due to earlier error
> Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.0.
Required by:
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.0
> Skipped due to earlier error
> Could not resolve net.sf.proguard:proguard-base:5.3.3.
Required by:
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > net.sf.proguard:proguard-gradle:5.3.3
> Skipped due to earlier error
> Could not resolve com.google.guava:guava:22.0.
Required by:
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:bundletool:0.1.0-alpha01 > com.google.protobuf:protobuf-java-util:3.4.0
> Skipped due to earlier error
> Could not resolve org.apache.httpcomponents:httpclient:4.2.6.
Required by:
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > com.android.tools.build:builder:3.1.4 > com.android.tools:sdklib:26.1.4
> Skipped due to earlier error
> Could not resolve org.apache.httpcomponents:httpmime:4.1.
Required by:
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > com.android.tools.build:builder:3.1.4 > com.android.tools:sdklib:26.1.4
> Skipped due to earlier error
> Could not resolve com.google.guava:guava:22.0.
Required by:
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > com.android.tools.build:builder:3.1.4 > com.android.tools:sdklib:26.1.4 > com.android.tools:repository:26.1.4 > com.google.jimfs:jimfs:1.1
> Skipped due to earlier error
So... Is there any chance to upgrade the version of this plugins that is crashing the build?
How can use the last version with pnpm
Hi!
I'm trying to implement this library and can't build android app. Looks like compile project(':react-native-exit-app')
is deprecated and implementation
need to be used instead.
Could you please help with this?
Error:
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method compile() for arguments [project ':react-native-exit-app'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Hello,
I am facing a problem with iOS build.
Currenlty I am using RN 0.73.2 and I need to build the app with static framework, so I am not 100% sure what the problem could be (if the newest Rn release or the static framework) anyway I got this error in RNExitApp.h
'React-Codegen/RNExitAppSpec/RNExitAppSpec.h' file not found` at line 10
#import <React-Codegen/RNExitAppSpec/RNExitAppSpec.h>
The error disappear (and I am able to build my app) if I change the line to #import <RNExitAppSpec/RNExitAppSpec.h>
so probably it is just necessary to update the code.
I can open PR if you want.
Thanks
Remove createJSmodules, it fails 0.47+ react builds,
Users/mdomarev/workspace/elmy-react-native/node_modules/react-native-exit-app/android/src/main/java/com/github/wumke/RNExitApp/RNExitAppPackage.java:26: error: method does not override or implement a method from a supertype
@OverRide
^
1 error
I'm getting this error when I'm using this library! Would you please help me to solve it?
Followed the instructions:
import RNExitApp from 'react-native-exit-app';
and calling
RNExitApp.exitApp()
This works well on IOS but not on Android. I am using jetify
Linked:
info iOS module "react-native-exit-app" is already linked
info Android module "react-native-exit-app" is already linked
"react-native-exit-app": "^1.1.0",
Getting
11-22 15:57:23.683 12470 12522 W ReactNativeJS: TypeError: null is not an object (evaluating '_reactNative.NativeModules.RNExitApp.exitApp')
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected]
for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-exit-app/android/src/main/java/com/github/wumke/RNExitApp/RNExitAppModule.java b/node_modules/react-native-exit-app/android/src/main/java/com/github/wumke/RNExitApp/RNExitAppModule.java
index c6d6299..5b250a1 100644
--- a/node_modules/react-native-exit-app/android/src/main/java/com/github/wumke/RNExitApp/RNExitAppModule.java
+++ b/node_modules/react-native-exit-app/android/src/main/java/com/github/wumke/RNExitApp/RNExitAppModule.java
@@ -1,6 +1,5 @@
package com.github.wumke.RNExitApp;
-import android.app.AlarmManager;
import android.app.Application;
import android.app.PendingIntent;
import android.content.Context;
@@ -19,12 +18,10 @@ import java.util.Date;
public class RNExitAppModule extends ReactContextBaseJavaModule {
ReactApplicationContext reactContext;
- AlarmManager alarmManager;
public RNExitAppModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
- alarmManager = (AlarmManager) reactContext.getSystemService(Context.ALARM_SERVICE);
}
@Override
@@ -34,6 +31,7 @@ public class RNExitAppModule extends ReactContextBaseJavaModule {
@ReactMethod
public void exitApp() {
- android.os.Process.killProcess(android.os.Process.myPid());
+ reactContext.getCurrentActivity().finishAndRemoveTask();
+ System.exit(0);
}
}
This issue body was partially generated by patch-package.
Hey.
Would you consider releasing a new version to npm? We really need #25 in our app.
Thanks
Version used: "react-native-exit-app": "^1.1.0"
Installation method:
yarn add react-native-exit-app react-native link react-native-exit-app
Error faced: null is not an object (Evaluating' _reactNative.NativeModules.RNExitApp.exitApp')
EDIT: Issue was resolved by manually linking the package. Maybe something could be done with react-native link react-native-exit-app
App deployed on iPhone flashbacks immediately after using this library...
How to solve this problem?
While deploying to Android works fine.
^ Title.
hi,
after I have been installed react native exit app on my project, when I want to exit my app by clicking exit button I get this error:
null is not an object ( evaluating 'reactNative.NativeModules.RNExitApp.exitApp')
thanks
"react": "16.8.3",
"react-native": "0.59.0",
"react-native-exit-app": "^1.1.0"
Greatly appreciate if a new npm version can be released.
This repo should have a prominent disclaimer saying that "Exiting an iOS app programmatically has historically been against Apple user interface guidelines and will likely cause your application to fail App Review if you plan to submit to the App Store".
Here is a related stack overflow thread.
https://stackoverflow.com/questions/8491466/call-exit0-in-iphone-app
Here is the specific reference from Apple user interface principles (The principles were removed from the Apple user interface guidelines as of 2017 but Apple has never said they aren't still being followed).
"Don’t Quit Programmatically
Never quit an iOS application programmatically because people tend to interpret this as a crash. However, if external circumstances prevent your application from functioning as intended, you need to tell your users about the situation and explain what they can do about it. Depending on how severe the application malfunction is, you have two choices.
Display an attractive screen that describes the problem and suggests a correction. A screen provides feedback that reassures users that there’s nothing wrong with your application. It puts users in control, letting them decide whether they want to take corrective action and continue using your application or press the Home button and open a different application
If only some of your application's features are not working, display either a screen or an alert when people activate the feature. Display the alert only when people try to access the feature that isn’t functioning."
I was investigating when I came across this library and saw this answer, outdated, but I also saw other comments on an Apple Developer forum stating that there are discussions about the AppStore rejecting application with this feature.
So, doing some tests with the current exitApp
method by adding the following:
RCT_EXPORT_METHOD(exitApp)
{
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] performSelector:@selector(suspend)];
});
};
The app is not killed instead, is close gracefully doing the animation to the home screen, like in the video below:
I want to know what could make more sense in order to have another way to close the app without killing it.
Would be good to have this feature at all? Of course, a different method to keep the other for those who seek close entirely the app.
I'm eager to work on this for both platforms.
iOS
Add RNExitApp.xcoderproj into your project in the Libraries folder.
Add the .a file on the General tab of your target under Linked Frameworks And Libraries
Add the .a file on the Build Phases tab of your target under Link Binary With Libraries
The project won't build with RN 0.56. react-native run-android
crashes with the following error:
/Users/ashoat/Dropbox/src/squadcal/native/node_modules/react-native-exit-app/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
/Users/ashoat/Dropbox/src/squadcal/native/node_modules/react-native-exit-app/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:4: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
/Users/ashoat/Dropbox/src/squadcal/native/node_modules/react-native-exit-app/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15:21-54: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
/Users/ashoat/Dropbox/src/squadcal/native/node_modules/react-native-exit-app/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
/Users/ashoat/Dropbox/src/squadcal/native/node_modules/react-native-exit-app/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
/Users/ashoat/Dropbox/src/squadcal/native/node_modules/react-native-exit-app/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15: error: Error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
We build app for native, but debugging and preview on web, it makes things go easier and fastest.
please add support for react-native-web, log warning instead of raise exception on web/react-native-web
TypeError
undefined is not an object (evaluating '_index.TurboModuleRegistry.getEnforcing')
Call Stack
eval code
:undefined:undefined
./node_modules/react-native-exit-app/NativeRNExitApp.ts
vendor.c3fb492439d06c32c09e.js:1627:5
undefined
main.8c71db7feb61bb2278b2.js:1506:35
__webpack_require__
main.8c71db7feb61bb2278b2.js:899:37
fn
main.8c71db7feb61bb2278b2.js:1145:28
eval code
:undefined:undefined
./node_modules/react-native-exit-app/index.js
vendor.c3fb492439d06c32c09e.js:1637:5
undefined
main.8c71db7feb61bb2278b2.js:1506:35
__webpack_require__
main.8c71db7feb61bb2278b2.js:899:37
fn
main.8c71db7feb61bb2278b2.js:1145:28
× Close
test environment:
"react-native-exit-app": "^2.0.0",
"react-native": "^0.72.6",
"react-native-web": "^0.19.7",
The implementation works well when the application is active / in foreground, but invoking RNExitApp.exitApp() while the application is in background does not remove it from Recent Apps even though android:autoRemoveFromRecents="true" in AndroidManifest.xml is configured.
Is there a way to deal with this issue?
Thank you!
Why is importing RNExitApp giving me undefined for both iOS and Android? I installed and linked correctly for both.
Android gradle change compile to implementation
When using RNExitApp.exitApp(); there is no way to remove app from recent apps.
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected]
for the project I'm working on.
I was seeing the following error when compiling
Declaration of 'RCTBridgeModule' must be imported from module 'React.RCTBridge' before it is required
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-exit-app/ios/RNExitApp/RNExitApp.m b/node_modules/react-native-exit-app/ios/RNExitApp/RNExitApp.m
index 44d27a2..3a61a49 100644
--- a/node_modules/react-native-exit-app/ios/RNExitApp/RNExitApp.m
+++ b/node_modules/react-native-exit-app/ios/RNExitApp/RNExitApp.m
@@ -1,5 +1,5 @@
#import <UIKit/UIKit.h>
-#import "RCTBridgeModule.h"
+#import <React/RCTBridgeModule.h>
@interface RNExitApp : NSObject <RCTBridgeModule>
This issue body was partially generated by patch-package.
Hi,
I'm using the latest (1.1.0
) version of this package, and when trying to build and run the app on Android, I get the following error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':react-native-exit-app'.
> Could not resolve all artifacts for configuration ':react-native-exit-app:classpath'.
> Could not resolve com.android.databinding:baseLibrary:3.1.4.
Required by:
project :react-native-exit-app > com.android.tools.build:gradle:3.1.4 > com.android.tools.build:gradle-core:3.1.4 > com.android.databinding:compilerCommon:3.1.4
> Could not resolve com.android.databinding:baseLibrary:3.1.4.
> Could not get resource 'https://jcenter.bintray.com/com/android/databinding/baseLibrary/3.1.4/baseLibrary-3.1.4.jar'.
> Could not HEAD 'https://jcenter.bintray.com/com/android/databinding/baseLibrary/3.1.4/baseLibrary-3.1.4.jar'.
> Read timed out
.. which makes sense because https://jcenter.bintray.com/com/android/databinding/baseLibrary/3.1.4/baseLibrary-3.1.4.jar is not reachable any more (403 Forbidden).
What can I do about this? I'm thankful for any hints. Thanks!
Latest changes works perfectly with React native 0.60.5.
Please push a new version to NPM
I just used the same android device to test my app and other apps.
My App: The quit app functionality is worked but without animation.
Other apps: Most of apps can be closed with animation.
Hi,
I faced the following error in iOS, but Android works well.
Does autolink work with ReactNative 0.72.6 ?
Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNExitApp' could not be found.
Verify that a module by this name is registered in the native binary., js engine: hermes
Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and
restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js
engine: hermes
ERROR Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNExitApp' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes
ERROR Invariant Violation: "main" has not been registered. This can happen if:
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
Expo bare workflow
"react-native": "0.72.6",
"react": "18.2.0",
"expo": "^49.0.0",
"react-native-exit-app": "^2.0.0",
didn't follow manual link yet.
(I don't know exactly how to do this.)
Add RNExitApp.xcoderproj into your project in the Libraries folder.
Add the .a file on the General tab of your target under Linked Frameworks And Libraries
Add the .a file on the Build Phases tab of your target under Link Binary With Libraries
When I try to build and app with export type appstore
, it's failing with this error:
clang: error: no such file or directory: '/Users/dorianmazur/Library/Developer/Xcode/DerivedData/HSEHealth-dfpjysdkkzjanwawxbicvhdzbohw/Build/Intermediates.noindex/ArchiveIntermediates/HSEHealth/BuildProductsPath/Release-appletvos/libRNExitApp.a'
In MainApplication.java, new RNExitAppPackage()
still has to be added manually despite using react-native link react-native-exit-app
react-native-cli: 2.0.1
react-native: 0.58.6
react-native-exit-app: 1.0.0
I'm also using Wix's react-native-navigation 2.21.1 and MainApplication.java file was modified.
i saw the package update. lol
can u update npm and yarn?
FAILURE: Build failed with an exception.
com.android.builder.errors.EvalIssueException: defaultConfig contains custom BuildConfig fields, but the feature is disabled.
To enable the feature, add the following to your module-level build.gradle:
android.buildFeatures.buildConfig true
as i mentioned above, react-native-exit-app-no-history dose not really kill the app
Hi wumke,
You have a GPL LICENSE file in your repo but your package.json specifies the license as ISC. It would be great if you could clarify (hopefully in favor of ISC :D)
RNExitApp.exitApp();
i need to to kill the app at certain cases, and i'm using expo.
does this work on expo?
My android app crash on Android 4.4.2 when exitApp() is called.
E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules Process: com.ctrack, PID: 10598 com.facebook.react.common.JavascriptException: undefined is not an object (evaluating 'd.NativeModules.RNExitApp.exitApp'), stack: exitApp@1292:135 onPress@1289:2218 <unknown>@85:2292 value@18:5166 <unknown>@18:1480 value@18:3828 value@18:1450 at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:56) at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:40) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) at android.os.Looper.loop(Looper.java:149) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194) at java.lang.Thread.run(Thread.java:841)
How can I fix it?
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.