Closed ghost closed 4 years ago
I have found out that it is indeed possible to set a global variable accessible from both React Native and iOS. So, if anyone would like to get started on the Objective C part, the interval between alerts will be set locally by the user in React Native as a property (see "Properties" in Facebook, 2019b) that can then be accessed from iOS. For documentation on how this will be done, please refer to the React Native documentation on Native UI Components for iOS (Facebook, 2019a).
References:
Facebook. (2019). Communication between native and React Native [Documentation]. Retrieved from https://facebook.github.io/react-native/docs/communication-ios
Facebook. (2019). Native UI Components [Documentation]. Retrieved from https://facebook.github.io/react-native/docs/native-components-ios#properties
BTW, this work is being done on the react-native branch.
I am actively working on this issue. To follow my progress, please refer to my fork at https://github.com/michaelgill1969/checkin
With the addition of the Firebase Cloud Function checkCheckins, push notifications in iOS seems to be working well.
There is currently no reliable way to issue check-in alerts when the app is closed or in the background on iOS using React-Native. This will need to be done from the AppDelegate in iOS after ejecting to ExpoKit (see Expo.io, n.d.). A local UNNotification should be sufficient for alerting the patient to check in. To get started, please refer to Apple (2019).
The alert should be issued at a regular interval that can be chosen by the user. Of course, there will need to be a global accessible from both the AppDelegate and React Native. Preferably, this should not require accessing Firebase from the native side.
The JS packages, react-native-background-task and react-native-background-fetch, are still being considered for Android, but they have too many limitations for iOS.
References:
liamzebedee. (2016, February 13). How can I run background tasks in React Native? [Forum post]. Retrieved from https://stackoverflow.com/questions/35376690/how-can-i-run-background-tasks-in-react-native
Apple. (2019). Scheduling a notification locally from your app [Documentation]. Retrieved https://developer.apple.com/documentation/usernotifications/scheduling_a_notification_locally_from_your_app
Expo.io (n.d.). Ejecting to ExpoKit [Documentation]. Retrieved from https://docs.expo.io/versions/v33.0.0/expokit/eject/