[TIMOB-24266] iOS: Be able to receive native delegates from app to native modules / Hyperloop
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-03-23T17:44:48.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.3.0 |
Components | Hyperloop, iOS |
Labels | n/a |
Reporter | Hans Knöchel |
Assignee | Hans Knöchel |
Created | 2016-12-31T15:51:05.000+0000 |
Updated | 2018-07-17T15:20:22.000+0000 |
Description
We are currently lacking support for a "non-hacky" solution to ping native modules / hyerloop modules about global app delegates. Example use-cases:
- Push notification delegates
- Background service delegates
- URL opening delegates
- Lifecycle delegates
We could either achieve this by sending notifications using the
NSNotificationCenter
or by writing a delegate that is called by our core and implemented by other modules that want to use it. Both solutions require a core-SDK change, rather than CLI/Hyperloop changes. I would prefer the latter solution, since it's more transparent clear to the developer and easier to extend.
Before implementing anything of this, we should scope the impact on the current SDK and the required delegates to be exposed.
PR (titanium_mobile/master): https://github.com/appcelerator/titanium_mobile/pull/9761 PR (titanium_mobile/7_1_X): https://github.com/appcelerator/titanium_mobile/pull/9849 PR (hyperloop.next/master): https://github.com/appcelerator/hyperloop.next/pull/267 Test-Case:
Create a native iOS-module (make sure to select the SDK compiled before)
Go to the module implementation and connect to the delegate (e.g. inside create the following method):
Add a native delegate method, e.g.
Build the module, it should work properly
New guide: https://wiki.appcelerator.org/display/guides2/iOS+modules%3A+Use+native+UIApplication+delegates+in+Hyperloop+and+native+modules
Will only native modules have access to these delegate events? A guide to bring this into JS (Ti controller) would be helpful.
Hyperloop example (will require Titanium 7.1.0 and Hyperloop 3.1.0):
[~Nirmalkumar_Patel] We have a [guide](https://wiki.appcelerator.org/display/guides2/iOS+modules%3A+Use+native+UIApplication+delegates+in+Hyperloop+and+native+modules) ready for the release :-). You can test it today if you manually build the SDK from the above pull-request and update the "titanium.js" (located in
modules/iphone/hyperloop/3.0.1/hooks/node_modules/hyperloop-metabase/templates/builtins/titanium.js
and add this property:[~hknoechel], as i understand it, this only allows to set one delegate. What if multiple modules want to make use of this feature? Wouldn't the modules override each others delegates and only the last module has its delegate method called? The same would then apply to Hyperloop, of course.
[~jvennemann] You are right, I will adjust the PR to make it more flexible for multiple hook-ins.
For the watchers of this ticket: You can use this changes today by using the [Hyperloop 3.1.0 Beta 1](https://github.com/appcelerator-modules/hyperloop-builds/releases) and latest Titanium master (
appc ti sdk install -b master
).For all developers who can't wait for the next stable release: I have compiled a custom "7.1.2" that is basically a 7.1.1.GA + the commits from this ticket. Download [here](https://www.dropbox.com/s/enfatxsle7o1d3a/mobilesdk-7.1.2-osx.zip?dl=1)!
Verified changes are in SDKs 7.3.0.v20180711185043 & 7.4.0.v20180715180240