diff --git a/tumeplayMobile/android/app/build.gradle b/tumeplayMobile/android/app/build.gradle index 53f196d7..933ed664 100644 --- a/tumeplayMobile/android/app/build.gradle +++ b/tumeplayMobile/android/app/build.gradle @@ -226,8 +226,9 @@ dependencies { exclude group: 'com.google.android.gms', module: 'play-services-base' exclude group: 'com.google.android.gms', module: 'play-services-maps' } - implementation 'com.google.android.gms:play-services-base:18.0.1' - implementation 'com.google.android.gms:play-services-maps:17.0.0' + implementation 'com.google.android.gms:play-services-base:18.0.1' + implementation 'com.google.android.gms:play-services-maps:17.0.0' + implementation project(':react-native-in-app-review') } // Run this once to be able to run the application with BUCK diff --git a/tumeplayMobile/android/app/src/main/java/com/tumeplaymobile/MainApplication.java b/tumeplayMobile/android/app/src/main/java/com/tumeplaymobile/MainApplication.java index f5b8142b..9a75987d 100644 --- a/tumeplayMobile/android/app/src/main/java/com/tumeplaymobile/MainApplication.java +++ b/tumeplayMobile/android/app/src/main/java/com/tumeplaymobile/MainApplication.java @@ -4,6 +4,7 @@ import android.content.Context; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; +import com.ibits.react_native_in_app_review.AppReviewPackage; import io.xogus.reactnative.versioncheck.RNVersionCheckPackage; import com.reactnativecommunity.webview .RNCWebViewPackage; import com.reactnativecommunity.webview.RNCWebViewPackage; @@ -19,6 +20,7 @@ import java.util.List; import de.bonify.reactnativematomo.MatomoPackage; + public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = @@ -31,6 +33,7 @@ public boolean getUseDeveloperSupport() { @Override protected List getPackages() { new MatomoPackage(); + new AppReviewPackage(); @SuppressWarnings("UnnecessaryLocalVariable") List packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for example: @@ -42,6 +45,7 @@ protected List getPackages() { protected String getJSMainModuleName() { return "index"; } + }; @Override diff --git a/tumeplayMobile/android/settings.gradle b/tumeplayMobile/android/settings.gradle index 95ff5a1a..62e6bff9 100644 --- a/tumeplayMobile/android/settings.gradle +++ b/tumeplayMobile/android/settings.gradle @@ -1,4 +1,6 @@ rootProject.name = 'tumeplay' +include ':react-native-in-app-review' +project(':react-native-in-app-review').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-in-app-review/android') include ':react-native-version-check' project(':react-native-version-check').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-version-check/android') include ':react-native-webview' diff --git a/tumeplayMobile/ios/Podfile b/tumeplayMobile/ios/Podfile index 939833d3..fa8d9d4d 100644 --- a/tumeplayMobile/ios/Podfile +++ b/tumeplayMobile/ios/Podfile @@ -25,6 +25,8 @@ target 'tumeplayMobile' do pod 'react-native-version-check', :path => '../node_modules/react-native-version-check' + pod 'react-native-in-app-review', :path => '../node_modules/react-native-in-app-review' + target 'tumeplayMobileTests' do inherit! :complete # Pods for testing diff --git a/tumeplayMobile/package-lock.json b/tumeplayMobile/package-lock.json index c5b26e76..a0a778c1 100644 --- a/tumeplayMobile/package-lock.json +++ b/tumeplayMobile/package-lock.json @@ -16,6 +16,7 @@ "react": "17.0.2", "react-native": "0.67.2", "react-native-copilot": "^2.5.1", + "react-native-in-app-review": "^4.1.1", "react-native-maps": "^0.30.1", "react-native-permissions": "^3.3.1", "react-native-picker-select": "^8.0.4", @@ -11602,6 +11603,11 @@ "react-native": "*" } }, + "node_modules/react-native-in-app-review": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/react-native-in-app-review/-/react-native-in-app-review-4.1.1.tgz", + "integrity": "sha512-kuZNKvawD9rICR8SEKSMRB1Ws5RjjyQScxVg/57dK8Yrx/CeVqSL5jJUJ1Nhl/MMxwP5XJ/keFcjTb2YRMglQw==" + }, "node_modules/react-native-iphone-x-helper": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.3.1.tgz", @@ -23376,6 +23382,11 @@ "dev": true, "requires": {} }, + "react-native-in-app-review": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/react-native-in-app-review/-/react-native-in-app-review-4.1.1.tgz", + "integrity": "sha512-kuZNKvawD9rICR8SEKSMRB1Ws5RjjyQScxVg/57dK8Yrx/CeVqSL5jJUJ1Nhl/MMxwP5XJ/keFcjTb2YRMglQw==" + }, "react-native-iphone-x-helper": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.3.1.tgz", diff --git a/tumeplayMobile/src/components/Orders/HomeOrdersInput.js b/tumeplayMobile/src/components/Orders/HomeOrdersInput.js index 0bd3eb1d..18a96282 100644 --- a/tumeplayMobile/src/components/Orders/HomeOrdersInput.js +++ b/tumeplayMobile/src/components/Orders/HomeOrdersInput.js @@ -237,7 +237,7 @@ const HomeOrdersInput = props => { errors[item.name] ? '#D42201' : '#EAE2D7' } activeUnderlineColor="#D42201" - value={values[item.name]} + value={values[item.name].trim()} onChangeText={handleChange(item.name)} keyboardType={item.isNumber ? 'numeric' : 'default'} /> diff --git a/tumeplayMobile/src/components/Orders/OrderConfirm.js b/tumeplayMobile/src/components/Orders/OrderConfirm.js index d03bacfd..420b93b0 100644 --- a/tumeplayMobile/src/components/Orders/OrderConfirm.js +++ b/tumeplayMobile/src/components/Orders/OrderConfirm.js @@ -86,7 +86,10 @@ const OrderConfirm = props => { const handleClosingModal = () => { if (!isLoading) { Event.boxOrdered(); - navigation.navigate('Home', {screen: 'Accueil'}); + navigation.navigate('Home', { + screen: 'Accueil', + params: {shouldReview: true}, + }); setIsVisible(false); } }; diff --git a/tumeplayMobile/src/components/Orders/Pickup/PickupOrderConfirm.js b/tumeplayMobile/src/components/Orders/Pickup/PickupOrderConfirm.js index c52e36ef..d6721c38 100644 --- a/tumeplayMobile/src/components/Orders/Pickup/PickupOrderConfirm.js +++ b/tumeplayMobile/src/components/Orders/Pickup/PickupOrderConfirm.js @@ -91,7 +91,10 @@ const PickupOrderConfirm = props => { const handleClosingModal = () => { if (!isLoading) { - navigation.navigate('Home', {screen: 'Accueil'}); + navigation.navigate('Home', { + screen: 'Accueil', + params: {shouldReview: true}, + }); setIsVisible(false); } }; diff --git a/tumeplayMobile/src/components/Orders/Pickup/PickupOrderUserInfos.js b/tumeplayMobile/src/components/Orders/Pickup/PickupOrderUserInfos.js index cb19dc98..13556558 100644 --- a/tumeplayMobile/src/components/Orders/Pickup/PickupOrderUserInfos.js +++ b/tumeplayMobile/src/components/Orders/Pickup/PickupOrderUserInfos.js @@ -80,7 +80,7 @@ const PickupOrderUserInfos = props => { { + if (InAppReview.isAvailable()) { + InAppReview.RequestInAppReview() + .then(hasFlowFinishedSuccessfully => { + console.log('InAppReview', hasFlowFinishedSuccessfully); + }) + .catch(error => { + console.log(error); + }); + } + }; + return { + onReview, + }; +} diff --git a/tumeplayMobile/src/views/HomePage.js b/tumeplayMobile/src/views/HomePage.js index 77fea744..5ba8e950 100644 --- a/tumeplayMobile/src/views/HomePage.js +++ b/tumeplayMobile/src/views/HomePage.js @@ -15,9 +15,11 @@ import config from '../../config'; import {WebView} from 'react-native-webview'; import Event from '../services/api/matomo'; import handleRedirection from '../services/handleRedirection'; +import useAppReview from '../hooks/useAppReview'; -const HomePage = ({navigation}) => { +const HomePage = ({navigation, route}) => { const {user} = useContext(AppContext); + const {onReview} = useAppReview(); const [tiktokHtmls, setTiktokHtmls] = useState([]); const tiktokIds = [ '7058603040588188933', @@ -49,6 +51,10 @@ const HomePage = ({navigation}) => { } }, [data, loading]); + useEffect(() => { + route?.params?.shouldReview && onReview(); + }, [route]); + const renderItem = ({item}) => { return (