Mobile Configuration

Documentation of Meteor's Cordova configuration API.

If your Meteor application targets mobile platforms such as iOS orAndroid, you can configure your app’s metadata and build processin a special top-level file calledmobile-config.js which is not included in your application and is used onlyfor this configuration.

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

  1. // This section sets up some basic app metadata, the entire section is optional.
  2. App.info({
  3. id: 'com.example.matt.uber',
  4. name: 'über',
  5. description: 'Get über power in one button click',
  6. author: 'Matt Development Group',
  7. email: 'contact@example.com',
  8. website: 'http://example.com'
  9. });
  10. // Set up resources such as icons and launch screens.
  11. App.icons({
  12. 'iphone_2x': 'icons/icon-60@2x.png',
  13. 'iphone_3x': 'icons/icon-60@3x.png',
  14. // More screen sizes and platforms...
  15. });
  16. App.launchScreens({
  17. 'iphone_2x': 'splash/Default@2x~iphone.png',
  18. 'iphone5': 'splash/Default~iphone5.png',
  19. // More screen sizes and platforms...
  20. });
  21. // Set PhoneGap/Cordova preferences.
  22. App.setPreference('BackgroundColor', '0xff0000ff');
  23. App.setPreference('HideKeyboardFormAccessoryBar', true);
  24. App.setPreference('Orientation', 'default');
  25. App.setPreference('Orientation', 'all', 'ios');
  26. // Pass preferences for a particular PhoneGap/Cordova plugin.
  27. App.configurePlugin('com.phonegap.plugins.facebookconnect', {
  28. APP_ID: '1234567890',
  29. API_KEY: 'supersecretapikey'
  30. });
  31. // Add custom tags for a particular PhoneGap/Cordova plugin to the end of the
  32. // generated config.xml. 'Universal Links' is shown as an example here.
  33. App.appendToConfig(`
  34. <universal-links>
  35. <host name="localhost:3000" />
  36. </universal-links>
  37. `);

App.info(options)

Set your mobile app's core configuration information.

Options

  • id, version, name, description, author, email, websiteString
  • Each of the options correspond to a key in the app's core configurationas described in the Cordova documentation.

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

Add a preference for your build as described in theCordova documentation.

Arguments

  • nameString
  • A preference name supported by Cordova'sconfig.xml.

  • valueString

  • The value for that preference.

  • platformString

  • 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 andare 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 andhot code push of new versions.

Read more about domain patterns in Cordovadocs.

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

Arguments

  • patternString
  • The pattern defining affected domains or URLs.

Options

  • typeString
  • 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.
  • launchExternalBoolean
  • (Deprecated, use type: 'intent' instead.)

For example this Cordova whitelist syntax:

  1. <access origin="https://www.google-analytics.com" />
  2. <allow-navigation href="https://example.com" />

is equivalent to:

  1. App.accessRule('https://www.google-analytics.com');
  2. App.accessRule('https://example.com', { type: 'navigation' });

App.configurePlugin(id, config)

Set the build-time configuration for a Cordova plugin.

Arguments

  • idString
  • The identifier of the plugin you want toconfigure.

  • configObject

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

Note: When using App.configurePlugin to re-configure a plugin which has been previously configured, the changes may not be reflected without manually clearing the existing Cordova build. To clear the existing Cordova build, remove the .meteor/local/cordova-build directory and re-build the application using either meteor run or meteor build.

App.icons(icons)

Set the icons for your mobile app.

Arguments

  • iconsObject
  • An Object where the keys are differentdevices and screen sizes, and values are image pathsrelative to the project root directory.

Valid key values:

  • app_store (1024x1024) // Apple App Store
  • iphone_2x (120x120) // iPhone 5, SE, 6, 6s, 7, 8
  • iphone_3x (180x180) // iPhone 6 Plus, 6s Plus, 7 Plus, 8 Plus, X
  • ipad_2x (152x152) // iPad, iPad mini
  • ipad_pro (167x167) // iPad Pro
  • ios_settings_2x (58x58) // iPhone 5, SE, 6, 6s, 7, 8, iPad, mini, Pro
  • ios_settings_3x (87x87) // iPhone 6 Plus, 6s Plus, 7 Plus, 8 Plus, X
  • ios_spotlight_2x (80x80) // iPhone 5, SE, 6, 6s, 7, 8, iPad, mini, Pro
  • ios_spotlight_3x (120x120) // iPhone 6 Plus, 6s Plus, 7 Plus, 8 Plus, X
  • ios_notification_2x (40x40) // iPhone 5, SE, 6, 6s, 7, 8, iPad, mini, Pro
  • ios_notification_3x (60x60 // iPhone 6 Plus, 6s Plus, 7 Plus, 8 Plus, X
  • ipad (76x76) // Legacy
  • ios_settings (29x29) // Legacy
  • ios_spotlight (40x40) // Legacy
  • ios_notification (20x20) // Legacy
  • iphone_legacy (57x57) // Legacy
  • iphone_legacy_2x (114x114) // Legacy
  • ipad_spotlight_legacy (50x50) // Legacy
  • ipad_spotlight_legacy_2x (100x100) // Legacy
  • ipad_app_legacy (72x72) // Legacy
  • ipad_app_legacy_2x (144x144) // Legacy
  • 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

  • launchScreensObject
  • A dictionary where keys are differentdevices, screen sizes, and orientations, and the values are image pathsrelative to the project root directory.

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

Valid key values:

  • iphone5 (640x1136) // iPhone 5, SE
  • iphone6 (750x1334) // iPhone 6, 6s, 7, 8
  • iphone6p_portrait (1242x2208) // iPhone 6 Plus, 6s Plus, 7 Plus, 8 Plus
  • iphone6p_landscape (2208x1242) // iPhone 6 Plus, 6s Plus, 7 Plus, 8 Plus
  • iphoneX_portrait (1125x2436) // iPhone X
  • iphoneX_landscape (2436x1125) // iPhone X
  • ipad_portrait_2x (1536x2048) // iPad, iPad mini
  • ipad_landscape_2x (2048x1536) // iPad, iPad mini
  • iphone (320x480) // Legacy
  • iphone_2x (640x960) // Legacy
  • ipad_portrait (768x1024) // Legacy
  • ipad_landscape (1024x768) // Legacy
  • android_mdpi_portrait (320x480)
  • android_mdpi_landscape (480x320)
  • android_hdpi_portrait (480x800)
  • android_hdpi_landscape (800x480)
  • android_xhdpi_portrait (720x1280)
  • android_xhdpi_landscape (1280x720)
  • android_xxhdpi_portrait (960x1600)
  • android_xxhdpi_landscape (1600x960)
  • android_xxxhdpi_portrait (1280x1920)
  • android_xxxhdpi_landscape (1920x1280)

App.appendToConfig(element)

Append custom tags into config's widget element.

App.appendToConfig('<any-xml-content/>');

Arguments

  • elementString
  • The XML you want to include