Skip to content

Commit 033dd81

Browse files
authored
Merge pull request #1140 from StoDevX/react-native-restart
Use react-native-restart to restart the app
2 parents 26dc609 + a6cb0d6 commit 033dd81

File tree

6 files changed

+42
-0
lines changed

6 files changed

+42
-0
lines changed

android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ dependencies {
192192
compile project(':react-native-maps')
193193
compile project(':react-native-network-info')
194194
compile project(':react-native-onesignal')
195+
compile project(':react-native-restart')
195196
compile project(':react-native-vector-icons')
196197
compile project(':react-native-view-shot')
197198
// this is for react-native itself

android/app/src/main/java/com/allaboutolaf/MainApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
// keep these sorted alphabetically
99
import com.airbnb.android.react.maps.MapsPackage;
10+
import com.avishayil.rnrestart.ReactNativeRestartPackage;
1011
import com.bugsnag.BugsnagReactNative;
1112
import com.BV.LinearGradient.LinearGradientPackage;
1213
import com.facebook.react.ReactApplication;
@@ -49,6 +50,7 @@ protected List<ReactPackage> getPackages() {
4950
new LinearGradientPackage(),
5051
new MapsPackage(),
5152
new ReactNativeOneSignalPackage(),
53+
new ReactNativeRestartPackage(),
5254
new RNDeviceInfo(),
5355
new RNNetworkInfoPackage(),
5456
new RNViewShotPackage(),

android/settings.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ project(':react-native-network-info').projectDir = new File(rootProject.projectD
2929
include ':react-native-onesignal'
3030
project(':react-native-onesignal').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-onesignal/android')
3131

32+
include ':react-native-restart'
33+
project(':react-native-restart').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-restart/android')
34+
3235
include ':react-native-vector-icons'
3336
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
3437

ios/AllAboutOlaf.xcodeproj/project.pbxproj

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
A0102781BF874C25BD76AD1D /* libRNDeviceInfo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A2D51A8982104BF29657933B /* libRNDeviceInfo.a */; };
4444
A90299E6C1BD45C385BBF8F0 /* libDBCustomTabs.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D222CA78E6554BBB83448435 /* libDBCustomTabs.a */; };
4545
BBDFD91C684046CB9FD0CD55 /* Entypo.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 742B362B86E443C09A7F9FD9 /* Entypo.ttf */; };
46+
C05E29F9598A4CA284DE922A /* libRCTRestart.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14483BC863F7489F8369E21B /* libRCTRestart.a */; };
4647
/* End PBXBuildFile section */
4748

4849
/* Begin PBXContainerItemProxy section */
@@ -130,6 +131,13 @@
130131
remoteGlobalIDString = 3D3CD9181DE5FBD800167DC4;
131132
remoteInfo = "jschelpers-tvOS";
132133
};
134+
006118571EE51CD100638440 /* PBXContainerItemProxy */ = {
135+
isa = PBXContainerItemProxy;
136+
containerPortal = DBE3B3C3883845C787D391C2 /* RCTRestart.xcodeproj */;
137+
proxyType = 2;
138+
remoteGlobalIDString = 3245CDED1BFEE35C00EABF68;
139+
remoteInfo = RCTRestart;
140+
};
133141
008413781D5C3AC30034750D /* PBXContainerItemProxy */ = {
134142
isa = PBXContainerItemProxy;
135143
containerPortal = 43E420DADB24468C9E296F25 /* RNVectorIcons.xcodeproj */;
@@ -360,6 +368,7 @@
360368
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = AllAboutOlaf/Images.xcassets; sourceTree = "<group>"; };
361369
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = AllAboutOlaf/Info.plist; sourceTree = "<group>"; };
362370
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = AllAboutOlaf/main.m; sourceTree = "<group>"; };
371+
14483BC863F7489F8369E21B /* libRCTRestart.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTRestart.a; sourceTree = "<group>"; };
363372
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
364373
150D47C893AB4ACBA45D7AF8 /* RCTGoogleAnalyticsBridge.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RCTGoogleAnalyticsBridge.xcodeproj; path = "../node_modules/react-native-google-analytics-bridge/ios/RCTGoogleAnalyticsBridge/RCTGoogleAnalyticsBridge.xcodeproj"; sourceTree = "<group>"; };
365374
17311DD2DB1B4EE0AFAA0BC4 /* RNViewShot.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNViewShot.xcodeproj; path = "../node_modules/react-native-view-shot/ios/RNViewShot.xcodeproj"; sourceTree = "<group>"; };
@@ -392,6 +401,7 @@
392401
CE0A6E16923B40C9930B546C /* ReactNativeCustomTabs.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = ReactNativeCustomTabs.xcodeproj; path = "../node_modules/react-native-custom-tabs/ios/ReactNativeCustomTabs.xcodeproj"; sourceTree = "<group>"; };
393402
D222CA78E6554BBB83448435 /* libDBCustomTabs.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libDBCustomTabs.a; sourceTree = "<group>"; };
394403
D530CE76BA714A59B2BECB28 /* libSafariViewManager.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libSafariViewManager.a; sourceTree = "<group>"; };
404+
DBE3B3C3883845C787D391C2 /* RCTRestart.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RCTRestart.xcodeproj; path = "../node_modules/react-native-restart/ios/RCTRestart.xcodeproj"; sourceTree = "<group>"; };
395405
E288E9E30083441F948E40BF /* RNSearchBar.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNSearchBar.xcodeproj; path = "../node_modules/react-native-search-bar/RNSearchBar.xcodeproj"; sourceTree = "<group>"; };
396406
E6FBE71A05CC43E2B4885180 /* Ionicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Ionicons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf"; sourceTree = "<group>"; };
397407
F803FE6585F04E9F8D3C053F /* libRCTGoogleAnalyticsBridge.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTGoogleAnalyticsBridge.a; sourceTree = "<group>"; };
@@ -437,6 +447,7 @@
437447
24A24E891B0D46F784E47912 /* libBugsnagReactNative.a in Frameworks */,
438448
9E5D73F8D3CC4F7499359624 /* libRNNetworkInfo.a in Frameworks */,
439449
1F80C8072BCE4729A1D62A16 /* libAirMaps.a in Frameworks */,
450+
C05E29F9598A4CA284DE922A /* libRCTRestart.a in Frameworks */,
440451
);
441452
runOnlyForDeploymentPostprocessing = 0;
442453
};
@@ -491,6 +502,14 @@
491502
name = Products;
492503
sourceTree = "<group>";
493504
};
505+
006118441EE51CD100638440 /* Products */ = {
506+
isa = PBXGroup;
507+
children = (
508+
006118581EE51CD100638440 /* libRCTRestart.a */,
509+
);
510+
name = Products;
511+
sourceTree = "<group>";
512+
};
494513
008413661D5C3AC30034750D /* Products */ = {
495514
isa = PBXGroup;
496515
children = (
@@ -729,6 +748,7 @@
729748
71D5CCADA66D45008D9A38F2 /* RNVectorIcons.xcodeproj */,
730749
17311DD2DB1B4EE0AFAA0BC4 /* RNViewShot.xcodeproj */,
731750
89FC2AFC0A394CFFAE89242D /* SafariViewManager.xcodeproj */,
751+
DBE3B3C3883845C787D391C2 /* RCTRestart.xcodeproj */,
732752
);
733753
name = Libraries;
734754
sourceTree = "<group>";
@@ -891,6 +911,10 @@
891911
ProductGroup = 00158A811E4FAE9E00F78C7B /* Products */;
892912
ProjectRef = 916377371C784A9B8A7A1F5C /* RCTOneSignal.xcodeproj */;
893913
},
914+
{
915+
ProductGroup = 006118441EE51CD100638440 /* Products */;
916+
ProjectRef = DBE3B3C3883845C787D391C2 /* RCTRestart.xcodeproj */;
917+
},
894918
{
895919
ProductGroup = 139105B71AF99BAD00B5F7CC /* Products */;
896920
ProjectRef = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */;
@@ -1045,6 +1069,13 @@
10451069
remoteRef = 0035C10C1E4F59AE00768B84 /* PBXContainerItemProxy */;
10461070
sourceTree = BUILT_PRODUCTS_DIR;
10471071
};
1072+
006118581EE51CD100638440 /* libRCTRestart.a */ = {
1073+
isa = PBXReferenceProxy;
1074+
fileType = archive.ar;
1075+
path = libRCTRestart.a;
1076+
remoteRef = 006118571EE51CD100638440 /* PBXContainerItemProxy */;
1077+
sourceTree = BUILT_PRODUCTS_DIR;
1078+
};
10481079
008413791D5C3AC30034750D /* libRNVectorIcons.a */ = {
10491080
isa = PBXReferenceProxy;
10501081
fileType = archive.ar;
@@ -1400,6 +1431,7 @@
14001431
"$(SRCROOT)/../node_modules/bugsnag-react-native/cocoa/**",
14011432
"$(SRCROOT)/../node_modules/react-native-maps/ios/**",
14021433
"$(SRCROOT)/../node_modules/react-native-network-info/ios",
1434+
"$(SRCROOT)/../node_modules/react-native-restart/ios/RCTRestart",
14031435
);
14041436
INFOPLIST_FILE = AllAboutOlaf/Info.plist;
14051437
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -1445,6 +1477,7 @@
14451477
"$(SRCROOT)/../node_modules/bugsnag-react-native/cocoa/**",
14461478
"$(SRCROOT)/../node_modules/react-native-maps/ios/**",
14471479
"$(SRCROOT)/../node_modules/react-native-network-info/ios",
1480+
"$(SRCROOT)/../node_modules/react-native-restart/ios/RCTRestart",
14481481
);
14491482
INFOPLIST_FILE = AllAboutOlaf/Info.plist;
14501483
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"react-native-network-info": "2.2.0",
8484
"react-native-onesignal": "3.0.4",
8585
"react-native-parallax-view": "2.0.6",
86+
"react-native-restart": "0.0.2",
8687
"react-native-safari-view": "2.0.0",
8788
"react-native-search-bar": "3.0.0",
8889
"react-native-sortable-list": "github:hawkrives/react-native-sortable-list#a46c78161e0a1a8d3a45f2fef69d98af3e911b6d",

source/lib/refresh.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// @flow
22
import {clearAsyncStorage} from './storage'
3+
import restart from 'react-native-restart'
34
import {clearLoginCredentials} from './login'
45

56
export async function refreshApp() {
67
await clearAsyncStorage()
78
await clearLoginCredentials()
9+
restart.Restart()
810
}

0 commit comments

Comments
 (0)