Mobile Configuration

Documentation of Meteor's Cordova configuration API.

If your Meteor application targets mobile platforms such as iOS or Android, you can configure your app’s metadata and build process in a special top-level file called mobile-config.js which is not included in your application and is used only for this configuration.

The code snippet below is an example mobile-config.js file. The rest of this section will explain the specific API commands in greater detail.

// This section sets up some basic app metadata,
// the entire section is optional.
App.info({
  id: 'com.example.matt.uber',
  name: 'über',
  description: 'Get über power in one button click',
  author: 'Matt Development Group',
  email: '[email protected]',
  website: 'http://example.com'

});

// Set up resources such as icons and launch screens.
App.icons({
  'iphone': 'icons/icon-60.png',
  'iphone_2x': 'icons/[email protected]',
  // ... more screen sizes and platforms ...

});

App.launchScreens({
  'iphone': 'splash/Default~iphone.png',
  'iphone_2x': 'splash/Default@2x~iphone.png',
  // ... more screen sizes and platforms ...

});

// Set PhoneGap/Cordova preferences
App.setPreference('BackgroundColor', '0xff0000ff');
App.setPreference('HideKeyboardFormAccessoryBar', true);
App.setPreference('Orientation', 'default');
App.setPreference('Orientation', 'all', 'ios');

// Pass preferences for a particular PhoneGap/Cordova plugin
App.configurePlugin('com.phonegap.plugins.facebookconnect', {
  APP_ID: '1234567890',
  API_KEY: 'supersecretapikey'

});

App.info(options)

Set your mobile app's core configuration information.

Options

id, version, name, description, author, email, website String

Each of the options correspond to a key in the app's core configuration as described in the Cordova documentation.

App.setPreference(name, value, [platform])

Add a preference for your build as described in the Cordova documentation.

Arguments

name String

A preference name supported by Cordova's config.xml.

value String

The value for that preference.

platform String

Optional. A platform name (either ios or android) to add a platform-specific preference.

App.accessRule(pattern, [options])

Set a new access rule based on origin domain for your app. By default your application has a limited list of servers it can contact. Use this method to extend this list.

Default access rules:

  • tel:*, geo:*, mailto:*, sms:*, market:* are allowed and are handled by the system (e.g. opened in the phone app or an email client)
  • http://localhost:* is used to serve the app's assets from.
  • The domain or address of the Meteor server to connect to for DDP and hot code push of new versions.

Read more about domain patterns in Cordova docs.

Starting with Meteor 1.0.4 access rule for all domains and protocols (<access origin="*"/>) is no longer set by default due to certain kind of possible attacks.

Arguments

pattern String

The pattern defining affected domains or URLs.

Options

type String

Possible values:

  • 'intent': Controls which URLs the app is allowed to ask the system to open. (e.g. in the phone app or an email client).
  • 'navigation': Controls which URLs the WebView itself can be navigated to (can also needed for iframes).
  • 'network' or undefined: Controls which network requests (images, XHRs, etc) are allowed to be made.
launchExternal Boolean

(Deprecated, use type: 'intent' instead.)

App.configurePlugin(id, config)

Set the build-time configuration for a Cordova plugin.

Arguments

id String

The identifier of the plugin you want to configure.

config Object

A set of key-value pairs which will be passed at build-time to configure the specified plugin.

App.icons(icons)

Set the icons for your mobile app.

Arguments

icons Object

An Object where the keys are different devices and screen sizes, and values are image paths relative to the project root directory.

Valid key values:

  • iphone_2x (120x120)
  • iphone_3x (180x180)
  • ipad (76x76)
  • ipad_2x (152x152)
  • ipad_pro (167x167)
  • ios_settings (29x29)
  • ios_settings_2x (58x58)
  • ios_settings_3x (87x87)
  • ios_spotlight (40x40)
  • ios_spotlight_2x (80x80)
  • android_mdpi (48x48)
  • android_hdpi (72x72)
  • android_xhdpi (96x96)
  • android_xxhdpi (144x144)
  • android_xxxhdpi (192x192)

App.launchScreens(launchScreens)

Set the launch screen images for your mobile app.

Arguments

launchScreens Object

A dictionary where keys are different devices, screen sizes, and orientations, and the values are image paths relative to the project root directory.

For Android, launch screen images should be special "Nine-patch" image files that specify how they should be stretched. See the Android docs.

Valid key values:

  • iphone_2x (640x960)
  • iphone5 (640x1136)
  • iphone6 (750x1334)
  • iphone6p_portrait (1242x2208)
  • iphone6p_landscape (2208x1242)
  • ipad_portrait (768x1024)
  • ipad_portrait_2x (1536x2048)
  • ipad_landscape (1024x768)
  • ipad_landscape_2x (2048x1536)
  • android_mdpi_portrait (320x470)
  • android_mdpi_landscape (470x320)
  • android_hdpi_portrait (480x640)
  • android_hdpi_landscape (640x480)
  • android_xhdpi_portrait (720x960)
  • android_xhdpi_landscape (960x720)
  • android_xxhdpi_portrait (1080x1440)
  • android_xxhdpi_landscape (1440x1080)

© 2011–2017 Meteor Development Group, Inc.
Licensed under the MIT License.
https://docs.meteor.com/v1.3.5/api/mobile-config.html