Posts

Post not yet marked as solved
1 Replies
1.7k Views
Hello everyone,I' working with a Raspberry Pi Zero W (having BLE) which reads the data from a temperature sensor, and makes a notification if necessary, I want to send this notification to my application written in Swift 3 for iOS, to display an alarm on the screen for example.I've been searching almost a week on Web but I have not found a method to do this finally, in fact I'm looking for a tutorial or example reference to do this. I don't know how I can use Core Bluetooth to communicate with my Raspberry Pi. That's why I would ask you if is possible for a solution either a reference or example or tutorial or book about on this subject, asking about communication between the Raspberry Pi Zero W and iOS application in Swoft 3 via BLE protocol.Thanks in advance,
Posted Last updated
.
Post not yet marked as solved
0 Replies
1.2k Views
Hello,It's about Xcode 8.3.2 and Swift 3 project.I'm using UserNotifications, by adding UNUserNotificationCenterDelegate in my AppDelegate classes.In order to recive the local notifications, I did these codes in my View Controller.swift : let yes = UNNotificationAction(identifier: "yes", title: "send SOS", options: .foreground) let no = UNNotificationAction(identifier: "no", title: "ignore", options: .foreground) let category = UNNotificationCategory(identifier: "cat", actions: [yes, no], intentIdentifiers: [], options: []) UNUserNotificationCenter.current().setNotificationCategories([category]) let content_2 = UNMutableNotificationContent() content_2.title = "You'r ok?!" content_2.body = "Alert!!" content_2.sound = UNNotificationSound.init(named: "SM.mp3") content_2.categoryIdentifier = "cat" let trigger_2 = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false) let request = UNNotificationRequest(identifier: "any", content: content_2, trigger: trigger_2) UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)And also these fonctions in my AppDelegate.swift : UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (allowed, error) in } UNUserNotificationCenter.current().delegate = self return true } func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { completionHandler([.alert, .badge, .sound]) } Until here, I can recive the local notifications. And work great.Problem : Normally when I am in View controller, I can open the sms interface window easily with these codes : let controller = MFMessageComposeViewController() controller.body = "SOS" controller.recipients = ["11111111111"] controller.messageComposeDelegate = self self.present(controller, animated: true, completion: nil)and this function : func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) { self.dismiss(animated: true, completion: nil) }But here my UNNotificationResponse function is in AppDelegate class, and I want to apply 2 actions, in my AppDelegate.swift for these responses : func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { / if response.actionIdentifier == "yes" { print("Envoyer SOS") } else { print("oui ca va") } }(Considering that I'll recive these notifications outside of my application, when it's suspending in background.)1- To open user interface sms windows with selecting "yes" as response.actionIdentifier.2 - To ignore the notification and rest outside of application by selecting "no" as response.actionIdentifier.I tested some methods but always either an error or crash.
Posted Last updated
.
Post not yet marked as solved
0 Replies
373 Views
Hello everybody,It's about Swift 3 in xcode for iOS 10.3 application.I know that we can customize the alert views using PCLBlurEffectAlert!This is the Reference.But I didn't find some reference to customize Local Notification Style.As I know in older iOS version, like iOS 9.3, it was possible to choice 3 differents Alert style in notificatios's setting : Non or Banners or Alerts, and the third option was Alerts style, that's what I'm looking for in iOS 10.3.I meen instead of having some notification Banners on the top of screen, I need to have a notification in the middle of screen just like an alarm clock notification, direct and with no need to any user's interaction (like swiping down), to see the eventuel options (title, subtitle, body and the answers : yes/no).I'm using User Notification in my project (Swift 3 for iOS 10.3), and I want to have one of this alert style in my application.Is it possible to customize or edit the notification style in iOS 10.3 (Swift 3 with xcode)?
Posted Last updated
.
Post not yet marked as solved
0 Replies
1.3k Views
Hello everybody,I'm using UserNotifications to listen some local notification in my application with Swift 3 and xcode.I need to put a countdown timer displaying on notification's little window or bar, counting from 10 to 0 when a notification arrive, to do some action automatically after this 10 secondes.Here is this part of code, when I recive a notification :(...) switch eventCode { case Stream.Event.hasBytesAvailable: if (alert == 1) { let yes = UNNotificationAction(identifier: "yes", title: "send SOS", options: .foreground) let no = UNNotificationAction(identifier: "no", title: "cancel", options: .foreground) timer.invalidate() time = 10 lbW.text = ("10") lbW.textColor = UIColor.clear timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(ViewController.action), userInfo: nil, repeats: true) lbW.textColor = UIColor.red let category = UNNotificationCategory(identifier: "cat", actions: [yes, no], intentIdentifiers: [], options: []) UNUserNotificationCenter.current().setNotificationCategories([category]) let content_2 = UNMutableNotificationContent() content_2.title = "Title" content_2.body = lbW.text! content_2.sound = UNNotificationSound.default() content_2.categoryIdentifier = "cat" content_2.badge = nmbAcc as NSNumber let trigger_2 = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false) let request = UNNotificationRequest(identifier: "any", content: content_2, trigger: trigger_2) UNUserNotificationCenter.current().add(request, withCompletionHandler: nil) }And Here the timer function : func action() { if(time <= 0) { timer.invalidate() time = 10 lbW.text = ("10") lbW.textColor = UIColor.clear } else { time -= 1 lbW.text = String(time) lbW.textColor = UIColor.red } } (...)Timer work well, and notifications alerte correctly, but I can't see somewhere in my codes,cause I don't know why the Body part of alert notification, (here on the line 27), don't display countdowt timer counting from 10 to 0 on notification's bar ?It just display the fixed timer number when the alert arrived. It just displays a counter sample, but not the active counter counting from 10 to 0.
Posted Last updated
.
Post not yet marked as solved
1 Replies
245 Views
I have an issue with my iOS app, written on Swift 3 with Xcode.I'm using WiFi Socket server Communication in my app to communicate with a Raspberry Pi via WiFi protocol, and UserNotification in Xcode to receive these notification sent from RPi.The problem is when I leave the application's window and go out to home screen, it seems my app stop to listening and when my RPi send the nothifications, there is no notification recived on my iPhone.When I test my application with Xcode simulator, it works well, on applications's window or out there on home screen,But when I test it on my iPhone device, it receive the notifications only when I rest on application's window, and stop working when I push the home's button on my iPhone to being on the home screen, or any where outside of application's windows.Maybe someone Know a solution,Thanks in advance,
Posted Last updated
.