我需要在带有10.2.1的iOS设备上发送带有使用Corona SDK构建的应用附件的电子邮件。我曾经一度构建了一个能够发送带附件的电子邮件的Corona应用程序,它运行得很好。现在,从iOS 10.2.1开始,它似乎无法工作,我无法判断它是否因为我编写的代码错误或native.showPopup
与iOS 10.2.1不兼容。
我正在使用Corona build 2017.3059。
此外,我已使用native.canShowPopup( "mail" )
检查了我的设备(iPhone 6),并指出该设备上提供了邮件弹出功能。
以下是我正在使用的代码。
local widget = require( "widget" )
-- Function to handle button event
local function sendMail( event )
if ( "ended" == event.phase ) then
if ( native.canShowPopup( "mail" ) ) then
native.showAlert( "Alert!", "Mail IS available on this device", { "OK" } )
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>"
}
native.showPopup( "mail", options )
else
native.showAlert( "Alert!", "Mail NOT available on this device", { "OK" } )
end
end
end
-- Create the widget
local mailButton = widget.newButton(
{
label = "Mail",
fontSize = 64,
onRelease = sendMail, -- this is my function to send mail
labelColor = { default={ 1, 1, 1 } },
labelAlign = "center",
emboss = false,
shape = "roundedRect",
width = 200,
height = 100,
cornerRadius = 13,
fillColor = { default={1,0,0}, over={0,1,1} },
strokeColor = { default={1,1,1}, over={1,1,1} },
strokeWidth = 4
}
)
mailButton.x = display.contentCenterX
mailButton.y = display.contentCenterY
答案 0 :(得分:0)
我能够让这个工作。实际上有两个问题:
1)由于某些原因,我的设备上的电子邮件帐户存在问题。
出于某种原因,我不确定为什么,我不得不删除我的电子邮件帐户并恢复它们,这似乎解决了问题。我觉得这是一种非常常见的配置,我在Apple iOS Mail应用程序上安装了两个Gmail帐户。但是删除它们并恢复它们就可以了。
2)您无法在触发电子邮件之前触发警告框
在我的代码正常工作之前,我不得不摆脱:
native.showAlert( "Alert!", "Mail IS available on this device", { "OK" } )
所以工作代码是:
local widget = require( "widget" )
-- Function to handle button event
local function sendMail( event )
if ( "ended" == event.phase ) then
if ( native.canShowPopup( "mail" ) ) then
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>"
}
native.showPopup( "mail", options )
else
native.showAlert( "Alert!", "Mail NOT available on this device", { "OK" } )
end
end
end
-- Create the widget
local mailButton = widget.newButton(
{
label = "Mail",
fontSize = 64,
onRelease = sendMail, -- this is my function to send mail
labelColor = { default={ 1, 1, 1 } },
labelAlign = "center",
emboss = false,
shape = "roundedRect",
width = 200,
height = 100,
cornerRadius = 13,
fillColor = { default={1,0,0}, over={0,1,1} },
strokeColor = { default={1,1,1}, over={1,1,1} },
strokeWidth = 4
}
)
mailButton.x = display.contentCenterX
mailButton.y = display.contentCenterY