diff --git a/example/RNBackgroundExample/.buckconfig b/example/RNBackgroundExample/.buckconfig deleted file mode 100644 index 934256cb..00000000 --- a/example/RNBackgroundExample/.buckconfig +++ /dev/null @@ -1,6 +0,0 @@ - -[android] - target = Google Inc.:Google APIs:23 - -[maven_repositories] - central = https://repo1.maven.org/maven2 diff --git a/example/RNBackgroundExample/.eslintrc.js b/example/RNBackgroundExample/.eslintrc.js deleted file mode 100644 index 40c6dcd0..00000000 --- a/example/RNBackgroundExample/.eslintrc.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - root: true, - extends: '@react-native-community', -}; diff --git a/example/RNBackgroundExample/.flowconfig b/example/RNBackgroundExample/.flowconfig deleted file mode 100644 index 757564ae..00000000 --- a/example/RNBackgroundExample/.flowconfig +++ /dev/null @@ -1,74 +0,0 @@ -[ignore] -; We fork some components by platform -.*/*[.]android.js - -; Ignore "BUCK" generated dirs -/\.buckd/ - -; Ignore polyfills -node_modules/react-native/Libraries/polyfills/.* - -; These should not be required directly -; require from fbjs/lib instead: require('fbjs/lib/warning') -node_modules/warning/.* - -; Flow doesn't support platforms -.*/Libraries/Utilities/LoadingView.js - -[untyped] -.*/node_modules/@react-native-community/cli/.*/.* - -[include] - -[libs] -node_modules/react-native/interface.js -node_modules/react-native/flow/ - -[options] -emoji=true - -esproposal.optional_chaining=enable -esproposal.nullish_coalescing=enable - -module.file_ext=.js -module.file_ext=.json -module.file_ext=.ios.js - -munge_underscores=true - -module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' -module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' - -suppress_type=$FlowIssue -suppress_type=$FlowFixMe -suppress_type=$FlowFixMeProps -suppress_type=$FlowFixMeState - -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+ -suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError - -[lints] -sketchy-null-number=warn -sketchy-null-mixed=warn -sketchy-number=warn -untyped-type-import=warn -nonstrict-import=warn -deprecated-type=warn -unsafe-getters-setters=warn -inexact-spread=warn -unnecessary-invariant=warn -signature-verification-failure=warn -deprecated-utility=error - -[strict] -deprecated-type -nonstrict-import -sketchy-null -unclear-type -unsafe-getters-setters -untyped-import -untyped-type-import - -[version] -^0.122.0 diff --git a/example/RNBackgroundExample/.gitattributes b/example/RNBackgroundExample/.gitattributes deleted file mode 100644 index d42ff183..00000000 --- a/example/RNBackgroundExample/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.pbxproj -text diff --git a/example/RNBackgroundExample/.gitignore b/example/RNBackgroundExample/.gitignore deleted file mode 100644 index 03e8f739..00000000 --- a/example/RNBackgroundExample/.gitignore +++ /dev/null @@ -1,63 +0,0 @@ -# OSX -# -.DS_Store - -# Xcode -# -build/ -*.pbxuser -!default.pbxuser -*.mode1v3 -!default.mode1v3 -*.mode2v3 -!default.mode2v3 -*.perspectivev3 -!default.perspectivev3 -xcuserdata -*.xccheckout -*.moved-aside -DerivedData -*.hmap -*.ipa -*.xcuserstate - -# Android/IntelliJ -# -build/ -.idea -.gradle -local.properties -*.iml - -# node.js -# -node_modules/ -npm-debug.log -yarn-error.log - -# BUCK -buck-out/ -\.buckd/ -*.keystore -!debug.keystore - -# fastlane -# -# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the -# screenshots whenever they are needed. -# For more information about the recommended setup visit: -# https://docs.fastlane.tools/best-practices/source-control/ - -*/fastlane/report.xml -*/fastlane/Preview.html -*/fastlane/screenshots - -# Bundle artifact -*.jsbundle - -artifacts/ - -# CocoaPods -/ios/Pods/ - -*.hprof diff --git a/example/RNBackgroundExample/.prettierrc.js b/example/RNBackgroundExample/.prettierrc.js deleted file mode 100644 index 5c4de1a4..00000000 --- a/example/RNBackgroundExample/.prettierrc.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - bracketSpacing: false, - jsxBracketSameLine: true, - singleQuote: true, - trailingComma: 'all', -}; diff --git a/example/RNBackgroundExample/.watchmanconfig b/example/RNBackgroundExample/.watchmanconfig deleted file mode 100644 index 9e26dfee..00000000 --- a/example/RNBackgroundExample/.watchmanconfig +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/example/RNBackgroundExample/App.js b/example/RNBackgroundExample/App.js deleted file mode 100644 index 06646904..00000000 --- a/example/RNBackgroundExample/App.js +++ /dev/null @@ -1,325 +0,0 @@ -/** - * Sample React Native App - * https://github.com/facebook/react-native - * - * @format - * @flow - */ - -import React, {useState} from 'react'; -import { - Alert, - SafeAreaView, - StyleSheet, - ScrollView, - View, - Text, - StatusBar, - Button, - Platform, - TouchableOpacity, -} from 'react-native'; - -import {Header, Colors} from 'react-native/Libraries/NewAppScreen'; - -import Upload from 'react-native-background-upload'; - -import ImagePicker from 'react-native-image-picker'; - -import RNFS from 'react-native-fs'; - -const url10SecDelayPut = 'http://localhost:8080/10secDelay'; -const url5secDelayFail = 'http://localhost:8080/5secDelayFail'; - -const path = RNFS.TemporaryDirectoryPath + '/test.json'; -const prefix = Platform.OS === 'ios' ? 'file://' : ''; - -const commonOptions = { - url: '', - path: prefix + path, - method: 'PUT', - type: 'raw', - // only supported on Android - notification: { - enabled: true, - }, -}; - -RNFS.writeFile(path, ''); - -const App: () => React$Node = () => { - const [delay10Completed, set10SecDelayCompleted] = useState(false); - const [delay5Completed, set5SecDelayCompleted] = useState(false); - - const [isImagePickerShowing, setIsImagePickerShowing] = useState(false); - const [uploadId, setUploadId] = useState(null); - const [progress, setProgress] = useState(null); - - const onPressUpload = options => { - if (isImagePickerShowing) { - return; - } - - setIsImagePickerShowing(true); - - const imagePickerOptions = { - takePhotoButtonTitle: null, - title: 'Upload Media', - chooseFromLibraryButtonTitle: 'Choose From Library', - }; - - ImagePicker.showImagePicker(imagePickerOptions, response => { - let didChooseVideo = true; - - console.log('ImagePicker response: ', response); - const {customButton, didCancel, error, path, uri} = response; - - if (didCancel) { - didChooseVideo = false; - } - - if (error) { - console.warn('ImagePicker error:', response); - didChooseVideo = false; - } - - // TODO: Should this happen higher? - setIsImagePickerShowing(false); - - if (!didChooseVideo) { - return; - } - - let finalPath = Platform.OS === 'android' ? path : uri; - - if (finalPath) { - // Video is stored locally on the device - Upload.getFileInfo(finalPath).then(metadata => { - const uploadOpts = Object.assign( - { - path: finalPath, - method: 'POST', - headers: { - 'content-type': metadata.mimeType, // server requires a content-type header - }, - }, - options, - ); - - Upload.startUpload(uploadOpts) - .then(uploadId => { - console.log( - `Upload started with options: ${JSON.stringify(uploadOpts)}`, - ); - setUploadId(uploadId); - setProgress(0); - Upload.addListener('progress', uploadId, data => { - if (data.progress % 5 === 0) { - setProgress(+data.progress); - } - console.log(`Progress: ${data.progress}%`); - }); - Upload.addListener('error', uploadId, data => { - console.log(`Error: ${data.error}%`); - }); - Upload.addListener('completed', uploadId, data => { - console.log('Completed!'); - }); - }) - .catch(function(err) { - setUploadId(null); - setProgress(null); - console.log('Upload error!', err); - }); - }); - } else { - // Video is stored in google cloud - Alert.alert('Video not found'); - } - }); - }; - - return ( - <> - - - -
- {global.HermesInternal == null ? null : ( - - Engine: Hermes - - )} - - - { - const options = { - ...commonOptions, - url: url10SecDelayPut, - }; - - Upload.startUpload(options) - .then(uploadId => { - console.warn(uploadId); - setUploadId(uploadId); - - Upload.addListener( - 'completed', - uploadId, - ({responseCode}) => { - console.warn({responseCode}); - - if (responseCode <= 299) { - set10SecDelayCompleted(true); - } - }, - ); - }) - .catch(err => { - console.warn(err.message); - }); - }}> - 10 Sec Delay Success - - - {delay10Completed && ( - - Finished!!! - - )} - - - { - const options = { - ...commonOptions, - url: url5secDelayFail, - }; - - Upload.startUpload(options) - .then(uploadId => { - console.warn(uploadId); - setUploadId(uploadId); - - Upload.addListener( - 'completed', - uploadId, - ({responseCode}) => { - console.warn(responseCode); - if (responseCode === 502) { - set5SecDelayCompleted(true); - } - }, - ); - - Upload.addListener( - 'error', - uploadId, - ({responseCode}) => { - set5SecDelayCompleted(true); - }, - ); - }) - .catch(err => { - console.warn(err.message); - }); - }}> - 5 Sec Delay Error - - - {delay5Completed && ( - - Finished!!! - - )} - -