Code Monkey home page Code Monkey logo

Comments (8)

myflashlab avatar myflashlab commented on June 16, 2024

Thanks for your interest. A little background information might be useful. You may know these already, but maybe this information can be helpful for someone else reading this :)

To be able to have access to the main iOS app delegate methods in AIR, we need to somehow override the methods in runtime. method conflicts in iOS can be avoided by changing the method names but when it comes to delegate methods, just renaming the methods is not good enough. Why? I explain this in simple terms.

Imagine you are building 2 different ANEs and you need didRegisterUserNotificationSettings in both of them. If you override this method in the first ANE, and then override it again in the second ANE, then it's crystal clear that only the later ANE will receive the callbacks from that method. So what happens to the first ANE? it will be broken and won't work as expected.

So, although there might be many different approaches to fix this problem, considering that our (myflashlabs Team) goal has been to allow other ANE developers to get around this problem easily without wasting time, we introduced the Override.ane.

One of its jobs is to override and catch the main app delegate methods and save a reference in the shared library of the static library we have created. Now, any other ANE which might require access to these methods, does not have to override them from scratch. They just need to listen to the Override.ane callbacks and act accordingly.

We should really find some time to write a complete blog post about this and gather the information organized in one place. but for now, this should help you. :D

Ok, enough with the theories. In my next post, I will provide you with a step-by-step tutorial on how you can use this helpful ANE.

from common-dependencies-ane.

amakovii avatar amakovii commented on June 16, 2024

Thank you very much for the response.
I realize that two libs with overridden functions can't work properly. I am looking forward to your next post with steps.

from common-dependencies-ane.

myflashlab avatar myflashlab commented on June 16, 2024

First, make sure you are updating to V4.1.0 and then, read this post. It should have everything you would need. If anything, feel free to ask. We'd be happy to help.

from common-dependencies-ane.

myflashlab avatar myflashlab commented on June 16, 2024

oops, here's the link: http://www.myflashlabs.com/efficiently-override-native-methods-air-native-extensions/

from common-dependencies-ane.

tuarua avatar tuarua commented on June 16, 2024

from common-dependencies-ane.

myflashlab avatar myflashlab commented on June 16, 2024

@tuarua I'm not sure I could understand your question... the job of the overrideAir ANE is to listen to the events and then dispatch them out to other ANEs. This way, only one ANE in your project will be listening to the native events.

from common-dependencies-ane.

tuarua avatar tuarua commented on June 16, 2024

I was asking whether using the observer pattern would allow each ANE to listen for events without needing an intermediary.

e.g. in Swift

NotificationCenter.default.addObserver(self, selector: #selector(ViewController.onApplicationDidFinishLaunching(notification:)), name: Notification.Name.UIApplicationDidFinishLaunching, object: nil)

@objc func onApplicationDidFinishLaunching(notification: Notification) {
        Swift.debugPrint("did finish launching")
    }

I saw in the FreshPlanet code that they are overriding the default function and thought there might be another way.

from common-dependencies-ane.

myflashlab avatar myflashlab commented on June 16, 2024

hmm, haven't tried it with the observers but still it seems like the main problem won't be answered with the use of observers.

In iOS, an event like applicationDidFinishLaunching will happen before the AIR apps runs. So an ANE cannot watch the event unless it is overriding it before the load time of the iOS app. If the first ANE is doing the override job and then the second one does the same, the first one will be lost. and if an observer is watching the applicationDidFinishLaunching I don't think it would ever be triggered simply because it is too late. The event is already dispatched and we have missed that!

That said, I think the observer can work totally fine for some other events that are happening after the AIR app has started.

from common-dependencies-ane.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.