Comments (4)
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 ofNSExtensionContext
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.
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.
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.
@DavidStrausz Thanks so much!
from cordova-plugin-today-widget.
Related Issues (6)
- PbxProject is not changed HOT 4
- Unable to run app after adding today widget HOT 2
- how to update widget message HOT 3
- Info.plist is missing HOT 3
- Publish to npm HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-today-widget.