cryonics-institute / checkin

A Mobile+Web Suite That Lets Those You Love Know You're OK; A Dead Man's Switch for Your Phone
GNU General Public License v3.0
3 stars 1 forks source link

Schedule Background Notifications to Alert Patient to Check In #31

Closed ghost closed 4 years ago

ghost commented 5 years ago

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/

ghost commented 5 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

ghost commented 5 years ago

BTW, this work is being done on the react-native branch.

ghost commented 4 years ago

I am actively working on this issue. To follow my progress, please refer to my fork at https://github.com/michaelgill1969/checkin

ghost commented 4 years ago

With the addition of the Firebase Cloud Function checkCheckins, push notifications in iOS seems to be working well.