OnlineJobs for iOS (v4.5.2) Bug

Last week, it was one of those times where you know something went wrong when suddenly you get multiple Slack notifications. I received a Slack notification for every minute, I had to mute the channel.

When I open the Bugsnag dashboard, I could see it was affecting hundreds of users. As of this moment, 154 users. Yikes!

What took me so long was that Bugsnag wasn’t able to capture all the other threads. I had to go back to Xcode’s Organizer Reports. I’ve been recently relying more on Xcode’s crash reports because they tend to be more detailed and well integrated with Xcode.

The bug was somewhere in this code block. This is for parsing an HTML String and it was crashing right on viewDidLoad() function.

extension Data {
    var html2AttributedString: NSAttributedString? {
        do {
            return try NSAttributedString(data: self, options: [
                .documentType: NSAttributedString.DocumentType.html,
                .characterEncoding: String.Encoding.utf8.rawValue
            ], documentAttributes: nil)
        } catch {
            return  nil
        }
    }
    var html2String: String {
        return html2AttributedString?.string ?? ""
    }
}
extension String {
    var html2AttributedString: NSAttributedString? {
        return Data(utf8).html2AttributedString
    }
    var html2String: String {
        return html2AttributedString?.string ?? ""
    }
}

Then I realized since in this ViewController I did not present this as full screen but in a modal kind of way, somehow it was affecting the lifecycle. The fix I did was to transfer the HTML parsing to viewDidAppear() function to give time to parse the HTML. ViewDidAppear is the callback that tells the ViewController that the views are added to the view hierarchy.

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    lastMessageLabel.text = message?.body?.html2String
}

That was it, the simple fix. Sorry guys, please download the latest OnlineJobs update v4.5.3.

If you like to receive daily mobile development posts, you can subscribe below. I’ll be posting frequently.

Processing…
Success! You're on the list.

Bintray Shutting Down

Next month, JFrog will shut down JCenter and Bintray and my experience with their service will go along with them.

Before Gradle, and all this new Android artifacts/dependencies repositories, Bintray was the most popular back in 2015. During that year, I was able to publish an Android package called Networking Valley, it’s still open source to this day. I called it Networking Valley to pay homage to a popular mobile game called Monumental Valley.

Networking Valley is a networking library for Android built using a combination of both Volley and OkHttp. You can use this on both HTTP and HTTPS request.

You might be wondering what’s up with “both HTTP and HTTPS”. See back in 2015, HTTPS wasn’t really widespread. You can publish an app with an HTTP backend, if I remember that right. So I wrote a networking library where I can “pin” an SSL certificate to every HTTP request. This library was very crucial because we used and generated a lot of self-signed SSL certificates and existing networking libraries don’t really support it.

Dynamic TableViewCell Height

I’m going to demonstrate on how I achieved the dynamic height for my UITableViewCell. Below is what it looks like.

This is a UITableViewCell for comments. ImageView on the left side is for the user’s avatar, the top most UILabel is for the username and lastly at the bottom is the UILabel for comment.

Yes don’t mind the red warnings, that is by design. The important here is for the UITableViewCell height to expand with AutoLayout.

First take note of the UIImageView’s constraints.

Next, the constraints for the username UILabel. As you may notice I did not specified a Height constraint, thus the red error for both UILabels.

And lastly the constraints for our comment UILabel.

Now in your code make sure you set the rowHeight and estimatedRowHeight to UITableView.automaticDimension

commentsTableView.rowHeight = UITableView.automaticDimension
commentsTableView.estimatedRowHeight = UITableView.automaticDimension

Nobody designs for small iPhone devices anymore

Nobody designs for small iPhone devices anymore. Why do I say this? Well, if you’ve been rocking the iPhone SE 2020 you would know. What I’m saying is there a lot of UI glitches from apps running on iPhone SE.

Clubhouse

Forgot to measure the screen’s width?

Spotify

I can’t see the Refresh button. I have to scroll up with my left thumb and then tap Refresh on my right. Smh.

Globe Telecom

If you can take a look at the bottom TabBbar. Labels are cut off.

Navigation bar is too large.

CloudMd

A little padding at the top on the menu.

Foodpanda

Too much white space padding at the top and the letters p and y on the Balance and payment methods are cut off.

Google Maps

Dang I can barely see the map.

Headspace

What’s up with them navigation bars?

I forgot but some local bank app

So many white spaces and concatenated Label. Too large fonts for my small ass phone.

Lalamove

My Drive logo all stretched out. Maybe check the AutoLayout constraints?

Contact word shouldn’t be too long right? And Address Book button why are you even there?

Apple Shortcuts

Dang how can I enter the folder name? Smh.

Medium

Navigation bar seems a little off. Too much white space for my small ass phone.

Pinterest

There’s too much padding on the navigation bar. For me it’s too much for my small phone and big thumb.

Apple TV

Too much header space don’t you think? I know the logo is perfectly done but how about conserving space.

Those are just some of the examples. I’m just too tired uploading it all. Also I might hit my blog GB limit.

As an iOS developer, I always pride myself in starting design and development using the smallest phone and screen size because it is easier to scale upwards than to scale downwards. Also, I don’t care if the statistics for small devices is less than 1%, it’s just pure respect for those users.

Maybe Apple should test on smaller devices before accepting the app on the App Store.