UILocalNotification design paradigm [closed] - ios

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have a few questions regarding UILocalNotifications and how I can design my app.
I have an application that monitors an FX (foreign exchange) data feed. What I want to do is add a feature where the user can set an alert to occur when the price hits a certain value.
There are then two scenarios - When the app is running and when it's not.
If the app is running then I can monitor the feed in the app and schedule and display a notification if the price is reached. (this I understand)
If it's not running then am I correct in my asumption that in order to monitor the feed my only option is to use the background task completion in iOS 6?
If so I guess this isn't going to work as I only get 15 minutes on background time, so after that there would be no way to monitor the feed and thus display a notification.
so.... A) is this a correct asumption? B) Is my only way to get longer than 15 minutes background time to use Push Notifications and monitor the feed on a server? C) How will iOS7 change this can I run arbitrary code in the background?
I have read the documenation but I cannot figure out how to present a UILocalnotifcation with a UIAlertView style look, rather than the drop down thing at the top of the screen?
If I schedule more than 64 notifications I understand the OS cancels any after that... Our of interest what if an app (malicious or not) setup 64 local notications (potentially repeating) how could a user cancel these if the app is badly coded and doesn't cancel them itself?? Would a restart destroy any scheduled notifications?
If I want to present a notificaiton when the app is running, do I bascailly catch the notficaiton in a delegate method and arrange to display the message myself?

So here are my ansers:
1A, Yes, the assumption is correct, your app can't run indefinitely in background
1B, Using PushNotifications won't give you longer time to execute in background, but your app can be notified at any time so this can be a a solution, but you can't rely on the notifications order so be careful.
1C I didn't check the latest features of iOS 7 but I doubt that they will provide indefinitely background running (like Android services)
2.Set the alertBody If the value of this property is non-nil, an alert is displayed but I don't think you can force the style of the alert, but if a user has set the style of the alerts then he will expect to receive them with that style so I think you shouldn't bother with this issue to much.
3.Not sure of this one, it's kind of tricky but you can test it ;)
4.YES, use application:didReceiveLocalNotification:

Related

Swift Notification based on BLE value when app it out of focus

I'm working on an iPhone app to control some custom BLE hardware. I am able to talk to my device and generate all required controls, but my problem now comes with setting up UserNotifications.
Part of the functionality of this device is to alert the user if one of the BLE characteristic values gets outside of a certain range. When the app is in focus, I am able to do this via UIAlerts. I have played with UserNotifications and I can trigger a notification while the app is focused so that the notification will appear after a specific interval. My issue is trying to generate a UserNotification based on data that's coming over a BLE connection in an app that's not focused.
I can tell via LED's on my hardware that the BLE connection is being maintained even while I'm out of focus/locked. Is there a way to evaluate data from a background BLE connection and create a UserNotification based on it?
I found This Question on StackExchange asking basically the same thing, but I'm hoping that several years later there may be more answers out there.
Cheers,
Roger
Paulw11 above mentioned the app being set up for background operation, which I was not aware of (I'm really new to IOS, I'm more of a low-level firmware guy).
It was just a matter of setting up Xcode background mode to let this run in the background, now I can alert the user regardless of whether the app is Active or Background.

Retrieving location updates in the background and send data on iOS [duplicate]

This question already has answers here:
How do I get a background location update every n minutes in my iOS application?
(14 answers)
Closed 4 years ago.
I am trying to get the users' location updates and send it to the server every 1 minute in the background in iOS.
The app needs to keep track of the driver’s position continuously similar to Uber and report it to our server every minute.
I tried background fetch and background locations and it runs fine for 3 minutes and then stops.
How do we accomplish this? Please advise.
Thanks in advance!
you cant accomplish exactly that, since An app cannot just run in the BG for a continous interval. (Exception for Bluetooth (sometimes) and Audio or VOIP
look for another way to do it:
==> besides background refresh, def. look at significant location updates (!) [Getting user location when app is in background. IOS

Swift Sprite-Kit - How To Add Notifications [duplicate]

This question already has answers here:
Local Notification on offline (Swift)
(2 answers)
Closed 4 years ago.
Iv'e been working on a topdown shooter game in Sprite-Kit using Swift and Xcode. I was wondering if there was a simple way to make a notification pop up if the user stops playing the app for a certain time (like 2 days for example.)
Also if I decide to add waiting in the future, can I make a notification pop up after and upgrade or something is complete? (this could also help other people viewing this post)
There is probably a similar way of doing these things but I would prefer if there was a simpler was as I am a bit new to Sprite-Kit and I don't want anything to complicated. A function would be nice if possible! :)
Thanks in advance!
If I am understanding you correctly sounds like the problem you are trying to solve has nothing to do with SpriteKit on it's own, but it's more related to triggering of a local or a push notification.
One way to achieve what you are trying to do is to make an object/module that it's sole responsibility is to count the application usage, when user opens the app or however you want to count that. You can trigger local notification that prompts the user that they haven't played the game for the past X days and every time the user uses the app you cancel the old notification and post a new one for the next X days.
Second option would be a server to manage the notifications via push notifications and your app will need to support push notification also tell the server whenever it's used so the server could notify if the app is not used for the past X days.

Send device location to web service from iOS at specific time of day [duplicate]

This question already has an answer here:
Call a web service from iOS at a particular time daily in the background
(1 answer)
Closed 4 years ago.
I would like to know how to run a scheduled method in an iOS app.
Every day, I have to send the device location to a web service twice a day. This submission must take place at 12:00 and 18:00. I used the method startMonitoringSignificantLocationChanges but it did not help me, because it has no exact time to run (as the name implies, only significant change of location). This feature should be performed automatically without user interaction with the iPhone because it is an "automatic check-in". It must be carried out with the app in any status (running or in background or terminated).
I found solutions that use the local notification, but the process should be completely transparent, without the user having to check-in, otherwise the feature would lose the concept.
How can this be done?
Dasdom is right - iOS doesn't allow you to schedule a background task. You can request the app run in the background, but cannot control when your code will actually be run (per Apple's guide, "When a good opportunity arises, the system wakes or launches your app into the background..."
Your best option is to have your service post an APNS notification to your application and handle the notification silently by posting the location back to your web service.

Trigger iOS app periodically

I'm trying to figure out if there is any permissible way to have my iOS app run periodically (say every 4 hours) and grab a users location. I'm aware of three possible ways this might be accomplished:
Local Notifications (Handling Local and Remote Notifications)
The problem with this solution is that when the app is killed after being in the background a while or the phone restarts, then the local notification will fire and give a UI but not actually start the app so I can't grab the location.
Alarms (Configuring Alarms)
As Apple's documentation says:
Note: An alarm is not intended to serve as a UILocalNotification. An alarm requires you to create an event or reminder that is visible in the user’s Calendar or Reminders app. A UILocalNotification is better suited for general purposes that don’t involve the Calendar database.
Therefore, not only would I be going against Apple's recommendation, but I would then have to ask for access to the user's calendar which won't make any sense to the user.
NSTimer (NSTimer)
I could create a NSTimer, but that solution was already answered here as not viable (That was three and a half years ago but I'm guessing the answer hasn't changed).
Are there any other ways in which this might be accomplished on iOS?
I don't know of any way to grab it periodically every X hours, but the Significant Change Location API might work for your use case. It gives you updates whenever there has been a significant change to the users location.
edit
If you app is not running in the background it will relaunch your app.
/edit
https://developer.apple.com/library/ios/documentation/userexperience/conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html#//apple_ref/doc/uid/TP40009497-CH2-SW10
This stack overflow question has a lot of info about this service also:
Behaviour for significant change location API when terminated/suspended?
See the Getting Location Events in the Background section of Apple's Location and Maps Programming Guide. The other methods mentioned in the question wouldn't actually wake the app up, except for UILocalNotification, and then only when the user tapped in in Notification Center.

Resources