2017-03-06 68 views
0

我想實現OneSignal Corna SDK用於接收推送通知, 但它給我一個運行時錯誤與實施OneSignal Corna SDK

棧回溯問題/Corona/Simulator/Plugins/plugin_OneSignal.lua:49:在功能「初始化」 main.lua:52:主塊

+0

[鏈接](https://documentation.onesignal.com/docs/corona-sdk)文檔和論壇[OneSignal] (https://forums.coronalabs.com/forum/640-onesignal/)。 – ldurniat

回答

0

此錯誤意味着有可能在你的代碼中的語法錯誤。請確保您已正確格式化的調用OneSignal init方法,像這樣:

-- This function gets called when the user opens a notification or one is received when the app is open and active. 
-- Change the code below to fit your apps needs. 
function DidReceiveRemoteNotification(message, additionalData, isActive) 
    if (additionalData) then 
    if (additionalData.discount) then 
     native.showAlert("Discount!", message, { "OK" }) 
     -- Take user to your app store 
    elseif (additionalData.actionSelected) then -- Interactive notification button pressed 
     native.showAlert("Button Pressed!", "ButtonID:" .. additionalData.actionSelected, { "OK"}) 
    end 
    else 
    native.showAlert("OneSignal Message", message, { "OK" }) 
    end 
end 

local OneSignal = require("plugin.OneSignal") 
-- Uncomment SetLogLevel to debug issues. 
-- OneSignal.SetLogLevel(4, 4) 
OneSignal.Init("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "############", DidReceiveRemoteNotification)