Recently I started developing an iOS app using Nativescript hybrid platform, I had this tasking of deep linking url where when we open a particular link the user should be redirected to the app instead of a web browser, so I googled about how to achieve it and a found a git-hub example in which the author leveraged native iOS events using custom delegate and implemented the events in UIApplication class.
I cloned his code and built the app to check if it was working, it was working as claimed. So, I followed all the steps. Installed required modules, created a custom delegate class, implemented functions and events e.t.c. Then I built my app and ran it. I was able to get the app opened when external link was pressed but the event which handles the redirection to particular view (or activity in android) was not getting triggered. I tried other event handlers which could access the external Urls, but to no avail. Only the applicationResumed event was getting triggered when application was coming into foreground. I tried to figure this out for one whole day without success, what could be wrong with my code, as the example app as working perfectly.
Next morning one of the senior developers looked at my code, He tried few things and finally he placed a print statement in the applicationResumed event, printing the object ‘this’. And once the applicationResumed event was triggered and the ‘this’ object was printed, we could see the function which handles redirections to the Urls was already overridden by another of the module I installed (firebase) which was using FBSdk which already overrode the events to handle the push notifications.
Once the issue was found all I had to do was edit the firebase module to handle my case also when the events gets triggered, thus solving my objective.
Most of the challenges in programming can be solved by using a new perspective or as we call it in our office ‘fresh eyes’. The best way to solve a problem is to attack the problem from all the directions possible and break the problem.
ps:- This is my first medium post, so please comment on how I can improve my content.