You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Expose all of the iOS UIApplicationDelegate methods as events in the application module #432
Currently we expose about 5 or 6 live cycle methods as events in the application module. For advanced scenarios (like push notifications) the clients will need to get the rest of the notifications.
IMO apple choose a terribly poor API design here.
As a side note, if we are not comfortable exposing like 30+ events on the application we can implement a chain-of-command. This would involve exposing for iOS an "addDelegate" and "removeDelegate" pair in the application module that can be used to add an instance of client implementation of the UIApplicationDelegate in an internal list. Our own UIApplicationDelegate will delegate all its implementation to the members of the internal list of UIApplicationDeleages. This way if new interfaces appear in future we won't have to bother changing the public JavaScript API. Also the development of modules may be somewhat easier since the developers won't have to memory map methods to event names and event args to actual arguments.
Almost half of the methods on UIApplicationDelegate aren't really events - we're talking stuff like state restoration, user activity continuation, background fetch, etc. Most of them are expected to return a meaningful value, or accept a callback block to execute when their respective task is complete. I don't believe that can map to events.
We just discussed with Panata that we are hitting more and more scenarios where we need various APIs available on the AppDelegate, which are currently not exposed at modules level. Hence, raising the priority of this issue.
The methods returning BOOL seem to indicate whether the app reacted/can react to the notification, which can be mapped to an event being handled, and eventually a sort of "stopImmediatePropagation" should be implemented properly.
In the case of the chain-of-command returning YES would mean the current delegate in the chain handled it / can handle it (and probably the rest should be ignored?). Returning YES if one of the delegates returned YES, and NO otherwise.
For these that accept notification block, the clients should be able to capture the block and call it later. In the case with the events all UIApplicationDelegate method arguments should be provided as properties on the event.
That's my thoughts about it. I am not sure these suggestions cover all cases.
New use-cases opened in iOS 9 will move the focus on:
I've researched this task and it seems that no matter what you return if you simply override some of the methods the framework will expect something from you. For example:
In this case you will get: Warning: Unable to create restoration in progress marker file
Furthermore there are callbacks such applicationDidReceiveRemoteNotificationFetchCompletionHandler that will expect special permission to be added that cannot be done automatically.
Maybe we should teach people how to declare such callbacks for the whole application only when needed and call some module/plug-in desired method(s) in this app callback - no UIApplicationDelegate callbacks handling inside components/modules. This is actually how Facebook SDK works.
I believe that we've found solution for this issue. Please check #547 for more info.
We do not have default UIApplicationDelegate anymore and developers can specify their own UIApplicationDelegate implementation using our brand new delegate property of iOSApplication class. For example:
Instead our built-in delegate in the previews version we use now NSNotificationCenter to handle events like UIApplicationDidFinishLaunchingNotification, UIApplicationDidFinishLaunchingNotification, etc. Furthermore developer can attach their own observers using our new API addNotificationObserver. For example:
Activity
fealebenpae commentedon Jul 14, 2015
Almost half of the methods on
UIApplicationDelegatearen't really events - we're talking stuff like state restoration, user activity continuation, background fetch, etc. Most of them are expected to return a meaningful value, or accept a callback block to execute when their respective task is complete. I don't believe that can map to events.atanasovg commentedon Jul 24, 2015
We just discussed with Panata that we are hitting more and more scenarios where we need various APIs available on the AppDelegate, which are currently not exposed at modules level. Hence, raising the priority of this issue.
PanayotCankov commentedon Jul 24, 2015
The methods returning BOOL seem to indicate whether the app reacted/can react to the notification, which can be mapped to an event being handled, and eventually a sort of "stopImmediatePropagation" should be implemented properly.
In the case of the chain-of-command returning YES would mean the current delegate in the chain handled it / can handle it (and probably the rest should be ignored?). Returning YES if one of the delegates returned YES, and NO otherwise.
For these that accept notification block, the clients should be able to capture the block and call it later. In the case with the events all UIApplicationDelegate method arguments should be provided as properties on the event.
That's my thoughts about it. I am not sure these suggestions cover all cases.
New use-cases opened in iOS 9 will move the focus on:
We can cover them case by case, but at the end, the clients should be able to react to everything in the UIApplicationDelegate.
enchev commentedon Jul 31, 2015
I've researched this task and it seems that no matter what you return if you simply override some of the methods the framework will expect something from you. For example:
In this case you will get:
Warning: Unable to create restoration in progress marker fileFurthermore there are callbacks such
applicationDidReceiveRemoteNotificationFetchCompletionHandlerthat will expect special permission to be added that cannot be done automatically.Maybe we should teach people how to declare such callbacks for the whole application only when needed and call some module/plug-in desired method(s) in this app callback - no UIApplicationDelegate callbacks handling inside components/modules. This is actually how Facebook SDK works.
Let me know your opinion.
enchev commentedon Aug 4, 2015
Hi,
I believe that we've found solution for this issue. Please check #547 for more info.
We do not have default
UIApplicationDelegateanymore and developers can specify their ownUIApplicationDelegateimplementation using our brand newdelegateproperty ofiOSApplicationclass. For example:Instead our built-in delegate in the previews version we use now
NSNotificationCenterto handle events likeUIApplicationDidFinishLaunchingNotification,UIApplicationDidFinishLaunchingNotification, etc. Furthermore developer can attach their own observers using our new APIaddNotificationObserver. For example:Let me know what you think!
Thanks
lock commentedon Aug 31, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.