2017-03-17 39 views
0

內置的應用程序,我需要從我的應用程序的附件與科羅娜SDK內置在iOS設備上使用10.2.1發送電子郵件。我曾經創建過一個Corona應用程序,它能夠發送帶有附件的電子郵件,並且工作得很好。現在,iOS版10.2.1的,它似乎並沒有工作,如果它是我不能說,因爲我寫的代碼錯誤,或者如果native.showPopup不與iOS兼容10.2.1。發送帶附件的郵件從科羅納在iOS 9.2.1

我使用電暈建設2017.3059。

另外,我還檢查了我的設備(iPhone的6)native.canShowPopup("mail"),它表明郵件彈出功能是可用的設備上。

以下是我正在使用的代碼。

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 = { "[email protected]", "[email protected]" }, 
      cc = { "[email protected]", "[email protected]" }, 
      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

我能夠得到這個工作。實際上有兩個問題:

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 = { "[email protected]", "[email protected]" }, 
      cc = { "[email protected]", "[email protected]" }, 
      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