native.showPopup()

Type Function
Library native.*
Return value Boolean
Revision Current Public Release (2013.1076)
Keywords email, sms, text message, store, show popup
Sample code /CoronaSDK/SampleCode/Networking/ComposeEmailSMS
See also Composing E-mail and SMS (tutorial)

Overview

Displays the operating system's default popup window for a specified service.

This function returns a Boolean indicating whether the popup was displayed or not. If it returns false, then the popup was not available or the service was not available for the device.

Compose E-mail and SMS

Passing in "mail" or "sms" will display a popup window for composing an E-mail or SMS message respectively.

For a walk-through on how to use this feature, please see the Composing E-mail and SMS tutorial.

On iOS, these popups are displayed within the app. On Android, the app is suspended while these popups are displayed.

Show App Details or Rate an App in the App Store

Passing in "appStore" will display a popup window from the app store that the application was downloaded from. It will display the app's details such as summary, an option to purchase (if not done already), and the option to write a review. This can be used to display the details of the currently running app or another app that you wish to advertise to the end-user.

Passing in "rateApp" will display the "Write Review" popup window from the iTunes App Store for iOS 5 and older iOS versions. This bypasses the app details on iTunes so that the end-user can easily rate the app. On iOS 6 or any other app store, the app's details popup window will be displayed instead, just like how it is done when passing in "appStore" to this function. This is because the other app stores do not support bypassing the app details view.

Only the following app stores are supported. A popup window will not be displayed for any other app store.

  • Amazon App Store
  • Google Play
  • iTunes App Store
  • Nook App Store
  • Samsung App Store

Note that the iTunes App Store and the Nook App Store require the app ID and EAN to be set in the options table in order to display the popup. All other app stores do not require any additional information.

Also, note that displaying this popup suspends the app on both iOS and Android.

Syntax

native.showPopup( name )
native.showPopup( name, options )
name (required)

String. The string name of the popup to be shown. It can be one of the following: "mail", "sms", "appStore", or "rateApp".

options (optional)

Table. Table of parameters. Each property of the table is also optional. See Format for options below.

Format for options

"mail"

For the "mail" popup, the following properties are supported:

  • options.to is a single string or an array of strings. Each string is an e-mail address of a recipient.
  • options.cc` is a single string or an array of strings. Each string is an e-mail address of a cc'd recipient.
  • options.bcc is a single string or an array of strings. Each string is an e-mail address of a bcc'd recipient.
  • options.attachment is a table of the form { baseDir=, filename= [, type=] }. For the 'type' property, use an appropriate MIME type such as "image". To send multiple attachments, you must create an array of these tables.
  • options.body is a string for the main body of the e-mail.
  • options.isBodyHtml is a boolean indicating whether the e-mail is HTML. By default, plain text is assumed.
  • options.subject is a string.

"sms"

For the "sms" popup, the following properties are supported:

  • options.to is a single string or an array of strings. Each string is a phone number of the recipient.
  • options.body is a string for the main body of the e-mail.

"appStore" and "rateApp"

For the "appStore" and "rateApp" popup, the following properties are supported:

  • options.iOSAppId is a string ID assigned to the app by the iTunes App Store.
  • options.nookAppEAN is a string ID assigned to the app by the Nook App Store.
  • options.androidAppPackageName is the unique package name string of the Android app to be displayed by the Google Play, Amazon, or Samsung app stores. This property is optional. If you do not provide a package name, then Corona will use the currently running app's package name by default. You should only set this if you want to display the app store details of another app.
  • options.supportedAndroidStores is an array of strings indicating which app stores are supported on Android. This is needed in case the app was not installed by an app store so that Corona knows which app store to display the popup from. This is especially needed while testing and debugging the app. The following string names are supported:
    • "amazon"
    • "google"
    • "nook"
    • "samsung"

"twitter"

NOTE: This popup is only available on iOS (iOS 5 and after) because Apple offers native OS support via TWTweetComposeViewController.

For the "twitter" popup, the following properties are supported.

  • options.image is a table of the form { baseDir=, filename= } to the image you wish to post.
  • options.message is a string that prepopulates the message.
  • options.listener is a listener that supports popup events.
  • options.url is a string for the url you wish to post. Alternatively, this can be an array of url strings.

Enterprise

Unlike Corona SDK, the twitter popup is not pre-baked into Corona Enterprise. Instead, you must add the corresponding plugin to your iOS Xcode project in order to access the twitter popup. Specifically, you should add the static library located at: CoronaEnterprise/Plugins/native-popup-twitter/ios/libnative-popup-twitter.a

Examples

Show an E-mail popup with one file attachment:

local options =
{
   to = "john.doe@somewhere.com",
   subject = "My High Score",
   body = "I scored over 9000!!! Can you do better?",
   attachment = { baseDir=system.DocumentsDirectory, filename="Screenshot.png", type="image" },
}
native.showPopup("mail", options)

Show an HTML E-mail popup with multiple correspondents and attachments:

local options =
{
   to = { "john.doe@somewhere.com", "jane.doe@somewhere.com" },
   cc = { "john.smith@somewhere.com", "jane.smith@somewhere.com" },
   subject = "My High Score",
   isBodyHtml = true,
   body = "<html><body>I scored over <b>9000</b>!!! Can you do better?</body></html>",
   attachment =
   {
      { baseDir=system.DocumentsDirectory, filename="Screenshot.png", type="image" },
      { baseDir=system.ResourceDirectory, filename="MyLogo.png", type="image" },
   },
}
native.showPopup("mail", options)

Show a simple SMS popup. User must select contacts in popup window:

local options =
{
   body = "I scored over 9000!!! Can you do better?"
}
native.showPopup("sms", options)

Show an SMS popup with multiple recipients. You must use phone numbers.

local options =
{
   to = { "1234567890", "9876543210" },
   body = "I scored over 9000!!! Can you do better?"
}
native.showPopup("sms", options)

Show a popup for rating the app on the app store.

local options =
{
   iOSAppId = "1234567890",
   nookAppEAN = "0987654321",
   supportedAndroidStores = { "google", "samsung", "amazon", "nook" },
}
native.showPopup("rateApp", options)

Show the app store details of another app that you wish to advertise.

local options =
{
   iOSAppId = "1234567890",
   nookAppEAN = "0987654321",
   androidAppPackageName = "my.other.app.",
   supportedAndroidStores = { "google", "samsung", "amazon", "nook" },
}
native.showPopup("appStore", options)