Code Monkey home page Code Monkey logo

Comments (4)

DavidStrausz avatar DavidStrausz commented on June 7, 2024

From the official Apple docs:

Opening the Containing App

In some cases, it can make sense for a Today widget to request its containing app to open. For example, the Calendar widget in OS X opens Calendar when users click an event. (Note that in iOS, a user may have to unlock the device before the containing app can open.) To ensure that your containing app opens in a way that makes sense in the context of the user’s current task, you need to define a custom URL scheme that both the app and its widgets can use.

A widget doesn’t directly tell its containing app to open; instead, it uses the openURL:completionHandler: method of NSExtensionContext to tell the system to open its containing app. When a widget uses this method to open a URL, the system validates the request before fulfilling it.

So you will probably need cordova-plugin-customurlscheme to create your own url-scheme, add it to your iOS app and then open your app via openUrl in your widget, then you will be able to send a parameter which tells your app that it was opened by your widget.

from cordova-plugin-today-widget.

Ovilia avatar Ovilia commented on June 7, 2024

Thanks @DavidStrausz ! That's really helpful! ❤️

Another question is, how to update the widget based on information from JavaScript? For example, a TODO list widget should get the list from the App. Would that be too much to ask? 🤦‍♂

from cordova-plugin-today-widget.

DavidStrausz avatar DavidStrausz commented on June 7, 2024

No problem, glad to help! :)

Usually you use shared user defaults to exchange (simple) data (your app and your widget are in the same app-group and can therefore access the same user defaults).
Check this article.

You will probably want to use cordova-plugin-nativestorage to save e.g. the TODO list. Especially this section will be of interest for your use-case.

If you need a more advanced data-exchange you could also think about sharing an API-key in the user defaults, so your widget and your app can access the same backend.

from cordova-plugin-today-widget.

Ovilia avatar Ovilia commented on June 7, 2024

@DavidStrausz Thanks so much!

from cordova-plugin-today-widget.

Related Issues (6)

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.