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 how to do it. However when I started working on my first iOS app(My Day Todos), it was a little before mid-2014, so Xcode 6 was still in beta and there was not a lot of stuff for Swift out there.
Notifications & native Html5 iOS app
When you run the code from the notifications branch in an iOS simulator or an iOS device, you will be presented with an interface, such as this.
Each of the buttons above trigger a function in the Swift based View Controller using the techniques described in this post.
Schedule notifications for test
private func setTestNotifications(){
var date = NSDate()
//4 calls before this
scheduleNotifications(date.dateByAddingTimeInterval(60), message: "5")
}
private func scheduleNotifications(date: NSDate, message: String) {
let notification:UILocalNotification = UILocalNotification()
notification.fireDate = date
notification.timeZone = NSTimeZone.defaultTimeZone()
notification.fireDate = date
notification.soundName = UILocalNotificationDefaultSoundName
notification.alertBody = message
UIApplication.sharedApplication().scheduleLocalNotification(notification)
}
Cancel all notifications
private func cancelNotifications(){
UIApplication.sharedApplication().cancelAllLocalNotifications()
/*
below is the code for cancelling specific notifications
for n:AnyObject in UIApplication.sharedApplication().scheduledLocalNotifications {
let not:UILocalNotification = n as UILocalNotification
let alertBody = not.alertBody!
if alertBody == "3" {
UIApplication.sharedApplication().cancelLocalNotification(not)
}
}*/
}
Print notifications to console
private func printNotifications(){
for n:AnyObject in UIApplication.sharedApplication().scheduledLocalNotifications {
let not:UILocalNotification = n as UILocalNotification
println("alertBody:(not.alertBody)")
}
}
So what is next?
Other useful tutorials
In addition to this, I have written several iOS tutorials with useful code samples.
Building a native iOS Currency converter app
In this post, I will talk about my approach when building a new iOS Currency Converter. I focus on how I start by defining a simple user story, understand what the user story is followed by how I can accomplish all that technically. This post focuses on the requirements specification to build an iOS mobile app. The concepts discussed here apply to both all mobile apps, this document is focused on iOS Currency Converter. The rest of this document is structured as follows
- iOS Currency Converter app requirements as mentioned in the assessment document
- Define the user story for the app
- A description of what the app will do
- Technical requirements i.e. what libraries or frameworks can be used to achieve this
- UI design samples for the minimal UI
- Some backend architecture design
- Decisions to adopt this style
- Lastly, Questions i.e. if any aspect of building this is not clear
You can read more in the link below
Building a native iOS Currency Converter app – My Day To-Do – Bhuman (mydaytodo.com)
Tutorial on animating rows in UITableView
This post is a tutorial on how to add, delete and reload rows in UITableView with animation. Shown below is some code that I wrote for Xcode playground. This code programmatically constructs a UIButton, UITableView, adds them to a view and styles them using auto layout constraints. Then, it randomly generates a number between 1 and 3 and shows how to either,
- Animate inserting a new row (UITableViewCell) into a UITableView
- How to delete and animate removal of a row (UITableViewCell) from a UITableView
- How to animate reloading a section of a UITableViewRow
The code also has the necessary comments that explains some of the things. You can read the full post below.
Build your first iOS app: A Tip Calculator
Ignoring the COVID-19 world we live in right now, going out to eat is something we all love and while we don’t mind tipping the wait staff, we often don’t understand the tip calculation. Hence, I thought that helping you make a tip calculator would be the best way to get you started on making your first iOS app. Don’t worry if you haven’t built anything in iOS prior to this, with the right instructions, it’s not hard. If I can do it, so can you. The rest of this article is structured as follows,
- We will talk a little bit about what the app is
- Talk about the starter project and Xcode environment
- Discuss some storyboard concepts and write some code
- Finally, conclude with what you can do next after building this app
You can read the rest of the post in the comment below.
Building your first iOS app – Tip Calculator – My Day To-Do (mydaytodo.com)
If you find any of my posts useful and want to support me, you can buy me a coffee 🙂
https://www.buymeacoffee.com/bhumansoni
Or you can buying or even try one of my apps on the App Store.
Also, if you can leave a review on the App Store or Google Play Store, that would help too.

0 Comments