Type function Library native.* Return value none Revision 2017.3060 Keywords native, showPopup, activity
Displays the activity popup window which corresponds to UIActivityViewController
on iOS. The set of activities depends on the items you specify.
native.showPopup( name, options )
String. The string name of the popup to be shown. For the Activity Popup plugin, use "activity"
.
Table. A table that specifies parameters for the popup — see the next section for details.
Array. Array of individual items. See Item Array below.
Array. By default, all built-in and compatible activities are shown. You can exclude an activity by specifying an array of strings where each corresponds to an activity. See Supported Activities below for valid string values.
Table. Only applicable on iPad. Defines the bounds of the object (typically a button) from which the iPad's popup emerges from. A convenience pattern is to pass the contentBounds
property of the object.
Table. Only applicable on iPad. An array of values which defines the directions in which the iPad's popup arrow may point. Valid values are "up"
, "down"
, "left"
, "right"
, or "any"
. The default is "any"
.
Listener. Listener which supports basic popup events. In addition, it supports the following additional properties:
event.action
(string) — Value of "sent"
or "cancelled"
.event.activity
(string) — Value corresponding to the Supported Activities.The item array is an array of individual items, where each item is a table that contains data on which activity is to be performed. Each individual item table must contain both type
and value
properties.
Different activities support different item types. Please refer to Apple's documentation for a reference of supported activity types.
The Activity plugin supports the following activity string values, each corresponding to a built-in activity on iOS.
String | Corresponding iOS Activity |
---|---|
"UIActivityTypePostToFacebook" |
UIActivityTypePostToFacebook |
"UIActivityTypePostToTwitter" |
UIActivityTypePostToTwitter |
"UIActivityTypePostToWeibo" |
UIActivityTypePostToWeibo |
"UIActivityTypeMessage" |
UIActivityTypeMessage |
"UIActivityTypeMail" |
UIActivityTypeMail |
"UIActivityTypePrint" |
UIActivityTypePrint |
"UIActivityTypeCopyToPasteboard" |
UIActivityTypeCopyToPasteboard |
"UIActivityTypeAssignToContact" |
UIActivityTypeAssignToContact |
"UIActivityTypeSaveToCameraRoll" |
UIActivityTypeSaveToCameraRoll |
"UIActivityTypeAddToReadingList" |
UIActivityTypeAddToReadingList |
"UIActivityTypePostToFlickr" |
UIActivityTypePostToFlickr |
"UIActivityTypePostToVimeo" |
UIActivityTypePostToVimeo |
"UIActivityTypePostToTencentWeibo" |
UIActivityTypePostToTencentWeibo |
"UIActivityTypeAirDrop" |
UIActivityTypeAirDrop |
local popupListener = {} function popupListener:popup( event ) print( "(name, type, activity, action):", event.name, event.type, tostring(event.activity), tostring(event.action) ) end local textItems = { { type = "string", value = "Hello World!" }, { type = "string", value = "Good night, and good luck." }, } local options = { items=textItems, listener=popupListener } native.showPopup( "activity", options )
local popupListener = {} function popupListener:popup( event ) print( "(name, type, activity, action):", event.name, event.type, tostring(event.activity), tostring(event.action) ) end local urlItems = { { type = "url", value = "http://www.coronalabs.com" }, { type = "url", value = "http://docs.coronalabs.com" }, } local options = { items=urlItems, listener=popupListener } native.showPopup( "activity", options )
local popupListener = {} function popupListener:popup( event ) print( "(name, type, activity, action):", event.name, event.type, tostring(event.activity), tostring(event.action) ) end local imageItems = { { type = "image", value = { filename = "world1.jpg", baseDir = system.ResourceDirectory } }, { type = "image", value = { filename = "world2.jpg", baseDir = system.ResourceDirectory } }, } local options = { items=imageItems, listener=popupListener } native.showPopup( "activity", options )
local popupListener = {} function popupListener:popup( event ) print( "(name, type, activity, action):", event.name, event.type, tostring(event.activity), tostring(event.action) ) end local itemsToShare = { { type = "image", value = { filename = "world1.jpg", baseDir = system.ResourceDirectory } }, { type = "url", value = "http://www.coronalabs.com" }, { type = "string", value = "Hello World!" }, } local options = { items=itemsToShare, listener=popupListener } native.showPopup( "activity", options )