Skip to content

Commit

Permalink
Merge pull request #28 from p2devs/ps/add-force-update
Browse files Browse the repository at this point in the history
feat: add Force Update feature and Firebase In-App Messaging support
  • Loading branch information
pushpender-singh-ap authored Dec 29, 2024
2 parents a1e72c1 + 69c23cb commit befcf74
Show file tree
Hide file tree
Showing 15 changed files with 223 additions and 46 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ global.jks
**/LocalComic/index.js
**/Actions/Download.js
**/OfflineComic/index.js
**/ForceUpdate/Func.js

#ignore app.json file
app.json
Expand Down
18 changes: 11 additions & 7 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {Provider} from 'react-redux';
import {PersistGate} from 'redux-persist/integration/react';
import {persistor, store} from './src/Redux/Store';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
import {RootNavigation} from './src/Navigation';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
import { persistor, store } from './src/Redux/Store';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { RootNavigation } from './src/Navigation';
import Loading from './src/Components/UIComp/Loading';
import Toast from 'react-native-toast-message';
import {PaperProvider} from 'react-native-paper';
import { PaperProvider } from 'react-native-paper';
import ForceUpdate from './src/Components/ForceUpdate';

/**
* The main App component that sets up the root of the application.
Expand All @@ -16,13 +17,16 @@ import {PaperProvider} from 'react-native-paper';
* @returns {JSX.Element} The root component of the application.
*/
const App = () => {


return (
<GestureHandlerRootView style={{flex: 1}}>
<GestureHandlerRootView style={{ flex: 1 }}>
<Provider store={store}>
<PersistGate loading={<Loading />} persistor={persistor}>
<PaperProvider>
<RootNavigation />
<Toast />
<ForceUpdate />
</PaperProvider>
</PersistGate>
</Provider>
Expand Down
3 changes: 2 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")

implementation platform('com.google.firebase:firebase-bom:33.1.0') // Add firebase bom
implementation(platform("com.google.firebase:firebase-bom:33.7.0")) // Import the BoM for the Firebase platform
implementation 'com.google.firebase:firebase-analytics' // Add firebase analytics
implementation("com.google.firebase:firebase-crashlytics") // Add firebase crashlytics
implementation("com.google.firebase:firebase-inappmessaging-display") // Add firebase inapp messaging

implementation ('com.facebook.soloader:soloader:0.12.1+')

Expand Down
3 changes: 2 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme"
android:supportsRtl="true">
android:supportsRtl="true"
android:gwpAsanMode="always">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down
3 changes: 2 additions & 1 deletion firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"messaging_auto_init_enabled": true,
"messaging_android_notification_channel_id": "high-priority",
"perf_auto_collection_enabled": false,
"google_analytics_automatic_screen_reporting_enabled": true
"google_analytics_automatic_screen_reporting_enabled": true,
"in_app_messaging_auto_collection_enabled": true
}
}
10 changes: 8 additions & 2 deletions ios/InkNest.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,10 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = "$(inherited) ";
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
Expand Down Expand Up @@ -820,7 +823,10 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = "$(inherited) ";
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
Expand Down
20 changes: 20 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ PODS:
- Firebase/Crashlytics (11.4.0):
- Firebase/CoreOnly
- FirebaseCrashlytics (~> 11.4.0)
- Firebase/InAppMessaging (11.4.0):
- Firebase/CoreOnly
- FirebaseInAppMessaging (~> 11.4.0-beta)
- Firebase/Messaging (11.4.0):
- Firebase/CoreOnly
- FirebaseMessaging (~> 11.4.0)
Expand Down Expand Up @@ -104,6 +107,13 @@ PODS:
- GoogleUtilities/Environment (~> 8.0)
- nanopb (~> 3.30910.0)
- PromisesObjC (~> 2.4)
- FirebaseInAppMessaging (11.4.0-beta):
- FirebaseABTesting (~> 11.0)
- FirebaseCore (~> 11.0)
- FirebaseInstallations (~> 11.0)
- GoogleUtilities/Environment (~> 8.0)
- GoogleUtilities/UserDefaults (~> 8.0)
- nanopb (~> 3.30910.0)
- FirebaseInstallations (11.4.0):
- FirebaseCore (~> 11.0)
- GoogleUtilities/Environment (~> 8.0)
Expand Down Expand Up @@ -1926,6 +1936,10 @@ PODS:
- FirebaseCoreExtension (<= 11.4.0)
- React-Core
- RNFBApp
- RNFBInAppMessaging (21.6.1):
- Firebase/InAppMessaging (= 11.4.0)
- React-Core
- RNFBApp
- RNFBMessaging (21.4.0):
- Firebase/Messaging (<= 11.4.0)
- FirebaseCoreExtension (<= 11.4.0)
Expand Down Expand Up @@ -2256,6 +2270,7 @@ DEPENDENCIES:
- "RNFBAnalytics (from `../node_modules/@react-native-firebase/analytics`)"
- "RNFBApp (from `../node_modules/@react-native-firebase/app`)"
- "RNFBCrashlytics (from `../node_modules/@react-native-firebase/crashlytics`)"
- "RNFBInAppMessaging (from `../node_modules/@react-native-firebase/in-app-messaging`)"
- "RNFBMessaging (from `../node_modules/@react-native-firebase/messaging`)"
- "RNFBPerf (from `../node_modules/@react-native-firebase/perf`)"
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
Expand All @@ -2275,6 +2290,7 @@ SPEC REPOS:
- FirebaseCoreExtension
- FirebaseCoreInternal
- FirebaseCrashlytics
- FirebaseInAppMessaging
- FirebaseInstallations
- FirebaseMessaging
- FirebasePerformance
Expand Down Expand Up @@ -2445,6 +2461,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/@react-native-firebase/app"
RNFBCrashlytics:
:path: "../node_modules/@react-native-firebase/crashlytics"
RNFBInAppMessaging:
:path: "../node_modules/@react-native-firebase/in-app-messaging"
RNFBMessaging:
:path: "../node_modules/@react-native-firebase/messaging"
RNFBPerf:
Expand Down Expand Up @@ -2478,6 +2496,7 @@ SPEC CHECKSUMS:
FirebaseCoreExtension: 4445e4cd877e0790c4af33bedca61eaef27b7513
FirebaseCoreInternal: f47dd28ae7782e6a4738aad3106071a8fe0af604
FirebaseCrashlytics: 41bbdd2b514a8523cede0c217aee6ef7ecf38401
FirebaseInAppMessaging: 711d4357e9e6cfab5123f67ce1ea1f63bbb6442d
FirebaseInstallations: 6ef4a1c7eb2a61ee1f74727d7f6ce2e72acf1414
FirebaseMessaging: f8a160d99c2c2e5babbbcc90c4a3e15db036aee2
FirebasePerformance: 89f9e52ea9d86d1819cde923a7ca397743df8593
Expand Down Expand Up @@ -2563,6 +2582,7 @@ SPEC CHECKSUMS:
RNFBAnalytics: e4b4e0d20810d12309e5522432fbf4c0f2b2c2e1
RNFBApp: 21cbda2e7d2657cd3c92f490c050f5f0905d2ff0
RNFBCrashlytics: 1f0f79d23fc26cebc5325edf685f69bb5b9493e2
RNFBInAppMessaging: 1500674838d6f688f8dac648b16b9cad3898505d
RNFBMessaging: 5bc9395c4d411f0411e6ea939dd61fd5247a3db8
RNFBPerf: 816ff369b041978ab7a10dcbdafff0e88dc6b39c
RNGestureHandler: 1e33ee267aaf61bbab6089d32df3b38c3024e3dd
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@react-native-firebase/analytics": "^21.4.0",
"@react-native-firebase/app": "^21.4.0",
"@react-native-firebase/crashlytics": "^21.4.0",
"@react-native-firebase/in-app-messaging": "^21.6.1",
"@react-native-firebase/messaging": "^21.4.0",
"@react-native-firebase/perf": "^21.4.0",
"@react-native-picker/picker": "^2.9.0",
Expand Down
88 changes: 88 additions & 0 deletions src/Components/ForceUpdate/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import React, { useEffect, useState } from 'react';
import {
View,
Text,
StyleSheet,
TouchableOpacity,
Image,
Modal,
Linking
} from 'react-native';
import { checkUpdate } from './Func';

const ForceUpdate = () => {
const [isForceUpdate, setIsForceUpdate] = useState(false);
useEffect(() => {
checkUpdate(setIsForceUpdate, handleUpdate)
}, []);

const handleUpdate = () => {
Linking.openURL('https://p2devs.github.io/InkNest/');
}

return (
<Modal visible={isForceUpdate} animationType="slide" transparent>
<View style={styles.container}>
<Image
source={{ uri: 'https://github.com/p2devs/InkNest/blob/main/.github/readme-images/icon.png?raw=true' }}
style={styles.image}
/>
<Text style={styles.title}>Update Required</Text>
<Text style={styles.message}>
A newer version of the app is available. Please update to continue using the app.
</Text>
<TouchableOpacity style={styles.updateButton} onPress={handleUpdate}>
<Text style={styles.updateButtonText}>Update Now</Text>
</TouchableOpacity>
</View>
</Modal>
);
};

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 30,
backgroundColor: 'rgba(0, 0, 0, 0.8)',
},
image: {
width: 200,
height: 200,
marginBottom: 20,
borderRadius: 20,
resizeMode: 'contain',
},
title: {
fontSize: 24,
fontWeight: 'bold',
color: '#FFFFFF',
marginBottom: 10,
},
message: {
fontSize: 16,
color: '#FFFFFF',
textAlign: 'center',
marginBottom: 20,
lineHeight: 24,
},
updateButton: {
backgroundColor: '#007BFF',
paddingVertical: 12,
paddingHorizontal: 24,
borderRadius: 8,
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.2,
shadowRadius: 3,
elevation: 3,
},
updateButtonText: {
color: '#FFFFFF',
fontSize: 16,
fontWeight: 'bold',
},
});

export default ForceUpdate;
23 changes: 23 additions & 0 deletions src/Components/Func/getReleases.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import axios from "axios";
import APICaller from "../../Redux/Controller/Interceptor";
import { Alert, Linking, Modal, View } from "react-native";
import DeviceInfo from "react-native-device-info";

export const getReleases = async (setLogs = null, navigation = null) => {
try {
let response = await APICaller.get('https://api.github.com/repos/p2devs/InkNest/releases')

if (setLogs) {
setLogs(response?.data);
}

return response?.data
} catch (error) {

if (navigation) {
navigation.goBack();
}

return null;
}
}
34 changes: 25 additions & 9 deletions src/Components/UIComp/MarkDown.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ const parseMarkdown = (text) => {
return <Text key={index} style={styles.h2}>{line.substring(3)}</Text>;
} else if (line.startsWith('### ')) {
return <Text key={index} style={styles.h3}>{line.substring(4)}</Text>;
} else if (line.startsWith('**') && line.includes('**')) {
return <Text key={index} style={styles.bold}>{line.replaceAll('**', '')}</Text>;
} else if (line.startsWith('* ')) {
return <Text key={index} style={styles.listItem}>{'\u2022'} {line.substring(2)}</Text>;
} else if (line.startsWith('- ')) {
return <Text key={index} style={styles.listItem}>{'\u2022'} {line.substring(2)}</Text>;
} else if (line.startsWith(' - ')) {
return <Text key={index} style={styles.subListItem}>{'\u2219'} {line.substring(4)}</Text>;
} else if (line.startsWith(' - ')) {
return <Text key={index} style={styles.subSubListItem}>{'\u2023'} {line.substring(7)}</Text>;
} else if (line.startsWith('> ')) {
return <Text key={index} style={styles.blockquote}>{line.substring(2)}</Text>;
} else if (line.startsWith('```')) {
Expand All @@ -26,8 +32,7 @@ const parseMarkdown = (text) => {
const url = line.substring(endIndex + 2, line.length - 1);
return <Text key={index} style={styles.link} onPress={() => Linking.openURL(url)}> {text}</Text >;
} else {
return <Text key={index} style={styles.paragraph
} > {line}</Text >;
return <Text key={index} style={styles.paragraph} > {line}</Text >;
}
});

Expand All @@ -50,30 +55,43 @@ const styles = StyleSheet.create({
color: "white",
fontSize: 28,
fontWeight: 'bold',
marginBottom: 10,
},
h2: {
color: "white",
fontSize: 24,
fontWeight: 'bold',
marginBottom: 10,
},
h3: {
color: "white",
fontSize: 18,
fontWeight: 'bold',
marginBottom: 10,
},
paragraph: {
color: "white",
fontSize: 16,
marginBottom: 10,
},
bold: {
fontWeight: 'bold',
color: "white",
fontSize: 16,
},
listItem: {
color: "white",
fontSize: 16,
marginBottom: 5,
paddingLeft: 20,
paddingLeft: 15,
},
subListItem: {
color: "white",
fontSize: 16,
marginBottom: 5,
paddingLeft: 30,
},
subSubListItem: {
color: "white",
fontSize: 16,
marginBottom: 5,
paddingLeft: 50,
},
blockquote: {
color: "white",
Expand All @@ -82,15 +100,13 @@ const styles = StyleSheet.create({
borderLeftWidth: 4,
borderLeftColor: '#ddd',
paddingLeft: 10,
marginBottom: 10,
},
codeBlock: {
color: "white",
fontFamily: 'monospace',
backgroundColor: '#f4f4f4',
padding: 10,
borderRadius: 5,
marginBottom: 10,
},
link: {
color: 'steelblue',
Expand Down
Loading

0 comments on commit befcf74

Please sign in to comment.