Skip to main content

Posts

Showing posts with the label local notification

Getting the user's permission to send them local notifications in iOS (using Swift)

Ok for iOS devices I think it will still be at least another year, till we have devices that are using versions earlier than iOS 8 ! so what does that mean? Problem Well, it means that if we are building an iOS app that works on both iOS 7 and 8 which uses a feature introduced in iOS 8, we need to check if that feature exists on the device before using it. Now the iOS app that I am building uses local notifications and in iOS 8 Apple introduced this feature to ask the user to receive LOCAL NOTIFICATIONS via   registerUserNotificationSettings . So what I wanted to do is check if the feature exists on the device the app is running on without checking the iOS version on the device via  UIDevice.currentDevice().systemVersion . Solution So turns out NSObject has this really useful method called instancesRespondToSelector , so I can solve my problem of finding out the presence of registerUserNotificationsSettings using the following code, UIApplication.instancesRespon...

Why can't I cancel a local notification in my iOS app?(in Swift)

Prelude I have mentioned the fact that I am working on my first iOS app in a number of my previous posts and as such I face a number of newbie/noob(?) problems. They are not really problems as much as they are simply things that I do not know, for e.g. the following, how do I get the day of the week? where is my string.replaceAll in Swift? knowing which local notification brought my app to foreground ? serving HTML content in an iOS app that works on iOS 7 and above Thankfully, I have managed to make at least one generic solution and contribute it to the community i.e. my open-source Xcode project template( HTML5StarterAppWithSwift ) which you can get from Github . So this post basically describes another very simple problem that I have found a solution to, but I do not fully understand why the problem was occurring in the first place. Introduction As I have mentioned in this post , my iOS app uses local notifications i.e. UILocalNotification   and i...

Local notifications in an Html5 powered iOS app(native)

Ok, so I have already written about why I decided to take the route of building an hybrid(Html5/Native) app, such that I get to know the native environment. So that post also mentions how I have built this Xcode starter project which can serve as a template for building html5 iOS apps using the Ionic framework.   Recently, I wrote about about how that initiative of mine helped someone . and what I have done now is created a branch, Notifications  which provides some sample code for adding local notifications to the project. In this post, I am going to talk about what is in the Notifications branch. Questions 1) Why build a Hybrid app such that I need to write some native code? Well one of the reasons outlined in my previous post , was that I wanted my app to use local notifications.   2) But scheduling local notifications is so simple, why add some sample code for it? Yes scheduling local notifications is simple and this tutorial does a good job of showing ho...

Knowing which notification caused the iOS app to resume

This was another one of those rather simple problems that took me a while to work out, mainly because of my approach to iOS development. So how am I approaching it? well since I am new to it, I tend to not know a lot of stuff so I generally have lots of problems that I need to solve. So if I get stuck on a problem, I will simply move onto one of the other problems that need to be solved and that I can solve and later, revisit the problem I was originally stuck on. This will allow my iOS knowledge to grow and something that is  not immediately obvious initially, will be so later on. Problem I have an iOS app that uses local notifications to create a more engaging user experience. The local notifications fall into one of two distinct categories and when the app resumes via a notification, it performs a set of "app resume/awake" behaviours that are relative to the notification category. Wow, even I would have trouble following what I just wrote, so let me just make this beyon...