GMSGeocoder gives Thread 5: EXC_BAD_ACCESS (code=1, address=0x0) in Notification service extension iOS

I want to use reverse Geocoding to get an address from a location coordinate inside my notification service extension.

But including this code.

GMSGeocoder().reverseGeocodeCoordinate(self.getLastSavedLocation().coordinate) { response, error in }

crashes the app (shown in attached image)

Removing this code runs the app fine. I am unable to figure out what did I do wrong. This same code works correctly inside the app but crashes in the notification extension, I tried using Apple's reverse geocoder that also works fine on extension, but GMSGeocoder crashes. Please let me know what can be done to fix it.

Crash Info


  • So, I contacted Apple technical support, and they clarified my issue.

    Here is what they told me,

    If you look at the crashing thread, you're crashing when you try to initialize OpenGL from EAGLContext:


    The issue here is that you cannot access graphics hardware "from the background":


    ...which, in the case of an NSE, means you can't use them at all. Note that while OpenGL is deprecated, that doesn't actually matter here. The same crash would occur if they were using metal. Our low We can't use level graphics APIs at all in an NSE.

    So the solution is to use Google's Geocoding API (but it is not free to use). https://developers.google.com/maps/documentation/geocoding/overview#ReverseGeocoding