I have a basic meteor project. I added the following cordova project that was used in the meteor examples. cordova-plugin-appsettings@1.0.2.
Meteor version is 3.1.
As per the cordova example project, it is the way to access settings is by window.plugins.AppSettings . However in my code window.plugins and window.cordova.plugins are undefined.
How do I access the cordova plugin in the code?
This is the code snippet
Meteor.startup(() => {
Accounts.onLogin(data => {
console.log('onLogin', Meteor.userId(), data);
addPlayerId(currentPlayerId);
});
if (!Meteor.isCordova) {
return;
}
let appId = null;
// eslint-disable-next-line no-undef
window.plugins.AppSettings.get(
['onesignalappid', 'universallink'],
configs => {
Hi @MeteorCoder,
you can format your code in this forum by using … see the image below.
I suppose you already added the platforms. Did you? Mobile | Meteor Guide
Also could you please try to add all cordova related code inside if (Meteor.isCordova) {} to make sure you only avail of it when running inside Cordova.
In your code cordova might be undefined in your linter because it is not recognized as a global object or because you run your project in a web environment.
If, for instance, you started this project on an Android or IOS emulator, and in the device debugger you get undefined … there is a problem.
Have you tried just with window.AppSettings
?
Thank you @nachocodoner . window.AppSettings
works. How would we know when to use window. , window.cordova.plugins or window.plugins.
It would be great if and when time permits to enhance the meteor example cordova project to 3.1. It could be a good reference application.
We already have a task to revisit the meteor/examples
, especially those showcasing native capabilities. This work is open to the community. If you manage to run it on newer Meteor versions, I’d appreciate a PR for validation.
It seems window.AppSettings
depends on the version of the Cordova plugin. The example might be outdated. I’m not sure if Meteor determines where plugins are exposed, such as in the root, window.cordova.plugins
, or window.plugins
. When revisiting the examples that could help clarify this and improve documentation.
Thanks for the suggestion