// show the alert self.presentViewController(alert, animated: true, completion: nil) } let = UIAlertController(title: "Heart Rate This will create the Warning", message: "Heart rate doesn't seem that will be shown in case good, Sending Text messages to emergency contacts, Reset HeartRate in healthKit", of Emergency. preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "OK", style: This will add action button UIAlertActionStyle.Default, handler: {action in self.phoneNotificationHandler() to the notification so when self.makeACall() })) the user clicks Ok the phone should make the call and text func makeACall(){ if let mainphone = defaults.valueForKey("phoneTF") { let = NSURL(string: "tel://"+(mainphone as! String))! UIApplication.sharedApplication().openURL(url) } } This is the function that will be called when the user clicks Ok on the alert notification when his heart rate is not good. The function will make a call to the user emergency contact that is saved to the AppGroup under the String name “mainphone”. @IBAction func saveBtnPressed() {
// show the alert self.presentViewController(alert, animated: true, completion: nil) } let = UIAlertController(title: "Heart Rate Warning", message: "Heart rate doesn't seem good, Sending Text messages to emergency contacts, Reset HeartRate in healthKit", preferredStyle: UIAlertControllerStyle.Alert) This will create the that will be shown in case of Emergency. alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: {action in self.phoneNotificationHandler() self.makeACall() })) This will add action button to the notification so when the user clicks Ok the phone should make the call and text func makeACall(){ if let mainphone = defaults.valueForKey("phoneTF") { let = NSURL(string: "tel://"+(mainphone as! String))! UIApplication.sharedApplication().openURL(url) } } This is the function that will be called when the user clicks Ok on the alert notification when his heart rate is not good. The function will make a call to the user emergency contact that is saved to the AppGroup under the String name “mainphone”. @IBAction func saveBtnPressed() {
ThesisV3Draft.docx