You’ll be glad to know that the winter hasn’t completely halted my progress. Granted, I took two weeks off and barely worked the other two but, I have not written over the last month because of a technical challenge rather than procrastination.
Cocoapods in Extensions
I’m sure every developer who’s built something for the Apple ecosystem knows about Cocoapods, it has made package management tolerable despite Apple’s disdain to using external packages. I’ve learned through this endeavor that most pods that provide great functionality for an App, fall apart when used for App Extensions. The GTMAppAuth and AppAuth pods which made Google Authentication effortless to implement in my app broke apart when I tried to use them in my Widget extension. The tokens necessary to authenticate Analytics APIs returned false. I’ve spent hours and hours researching and tried to build my own implementation using AppAuth/Core for extensions, sadly, to no avail.
The Way Forward
So, this looks like a major stumbling block but, the Google Drive app has an iOS Widget so, I’m sure there is a way this can be achieved. I’m going to take a two-pronged approach to solve this problem,
- Call the API from the widget – This would entail multiple scenarios. I’m going to try and build pods differently for App and App extensions so no unavailable APIs’ are used. If that fails, I’ll try Google Sign-In for iOS and check if that supports Google Authentication from extensions.
- Use background app refresh to populate the widget – I’ll abandon using a network call during widget refresh and instead use background fetch to get the data I need. I’m going to store this data in a local database and use it to populate the widget when it’s refreshed.
I’m going to be focusing on hacking my way through these pathways over the next two weeks. The calling of API from the widget is still the preferred option so, I will try and implement that version first. I’ll hopefully have some good news in 2 weeks’ time.