Local Receipt Validation in Swift 3
When using StoreKit, there are two ways to validate a receipt. One is to validate with the App Store. It’s recommended if you are doing it from a trusted server. The procedure is straightforward and easy to implement. However, if you want to validate a receipt from the device directly, while “a trusted connection between a user’s device and the App Store directly” is not possible as stated by Apple, you’d better to choose the other way, which is to validate the receipt locally.
The local validation is not as easy as to validate with the App Store service. Meanwhile, Apple believe the approach should not base on the same implementation due to security consideration and doesn’t provided a complete sample code for you to copy and paste, which makes it even harder. objc.io had a wonderful article on how to do it in Objective-C. There are also some articles about how to do it in Swift but are either incomplete or obsolete somehow.
In this series, I kept a record on how I made it for iOS in Swift 3.
The implementation is under Xcode 8 with iOS 10 SDK. The ultimate document from Apple about the this can be found at
General->Guides->Receipt Validation Programming Guide. I won’t leave a link here since it changes all the time. Just check it out in Xcode.
About the next release of Tooth Fairy
I am really glad that Tooth Fairy was mentioned by MacStories. I got quite a lot emails from users suggesting on hiding the dock icon. Some of them even kindly sent stackoverflow links on how to do it.
In fact, in the very beginning, I made Tooth Fairy as a pure menu bar app without a dock icon. For a simple app like this, it can’t be other way than that. I even didn’t need to draw an icon for it. The only dilemma here is that since the click on the menu bar is occupied, I can only use right click to trigger the menu for preferences and quit. It’s not so obvious so I made a popup to notify users during first launch and even added a description in the preferences window. Then I submitted it to the Mac App Store.
No wonder, rejected by violating the HIG immediately .
The user interface of your app is not consistent with the OS X Human Interface Guidelines. Specifically:
We found the app requires the user right-click the menubar extra to access quit and preference options. This is not an expected behavior. It would be appropriate to allow the user to quit your application in a more obvious manner.
I wanted my app to release and didn’t want to play smart with the app store reviewers any more. So I added it back to the dock and made an icon. The app passed the review finally.
Now the app is in the store and I have more time to try more solutions with the reviewers. I’ve already submitted an update to add the options to hide dock icon and launch at login. Hope it can pass the review soon.
Tooth Fairy for Mac Released
I got a PowerBeats3 as a new year gift. It’s powered by W1 exactly as AirPods. Although it’s not as wireless and light weight as AirPods, it has all the benefits I wanted: water proof, physical touch control and not as easy to lose as AirPods.
The feature I like the most is how it connects to my devices. I use my earphone mostly during work and always need to switch the connection between my Mac and iPhone. Before PowerBeats3, I used a Beats Solo 2. It’s already quite easy to do the switching. All I have to do is to disconnect, which can be done from the Solo 2, and then connect by selecting from the other device. PowerBeats3, as AirPods and all the other earphones powered by W1, make it easier by skipping the disconnect step. You can just select connect from the device you want and done. On a Mac, it means you need to click on the volume icon or bluetooth icon from the menu bar and select the earphone from the popup menu. Simple, right? But can it be simpler?
So, here’s how Tooth Fairy comes. It’s a very simple app. It removes one more step to build the connection from your Mac to the bluetooth device you choose with just a single click on the menu bar icon, or even more, one hotkey so that you don’t need to go through the menu to identify your bluetooth device again.
If you like the idea, you can find the Tooth Fairy App at Mac App Store. If you have any thoughts or suggestion, just let me know.