Just tested on iOS and the "dialog" == event.type
is not firing as well. I do get an applicationOpen
system event though with a different URL for app sharing and webview sharing
Im guessing something broke with last v4a plugin build on August.
Edit: Here is my current source code if it helps or anything
local facebook = require("plugin.facebook.v4a")
local socketUrl = require("socket.url")
local settings = require("settings")
local json = require("json")
local service = {}
------------------------- Vars
local token
local userName, userId
local onShare, onMe
local isSimulator = system.getInfo("environment") == "simulator"
------------------------- Functions
local function listener( event )
if "fbinit" == event.name then
facebook.publishInstall()
token = facebook.getCurrentAccessToken() -- Is nil when player has never connected
if token then
facebook.request("me/")
end
elseif "fbconnect" == event.name then
if "session" == event.type then -- Login
if not event.isError then
token = facebook.getCurrentAccessToken()
if token then
facebook.request("me/")
end
end
elseif "request" == event.type then
if not event.isError then
local response = json.decode(event.response)
local name = response.name
local id = response.id
if onMe then
onMe({name = name, id = id})
end
end
elseif "dialog" == event.type then
print(event.response) -- This does not work
end
end
end
local function hexToChar(hex)
return string.char(tonumber(hex, 16))
end
local function unescape(text)
return string.gsub(text, "%%(%x%x)", hexToChar)
end
local function decodeQuery(url)
local result = {}
for key, value in string.gmatch(url, "([^&=?]-)=([^&=?]+)") do
local unescaped = unescape(value)
result[key] = json.decode(unescaped)
end
return result
end
local function parseUrl(url)
local result = socketUrl.parse(url)
if result then
local decodedQuery = result.query and decodeQuery(result.query)
return result.scheme, result.path, decodedQuery
end
return false
end
local function handleNotifications(event)
if event.type == "applicationOpen" then
timer.performWithDelay(1, function()
local scheme, path, query = parseUrl(event.url)
if scheme and scheme == settings.fbScheme then
if query then
if query.method_results then -- Tested iphone x facebook app
if (query.method_results.completionGesture == "post") and query.method_results.didComplete then
if onShare then
onShare()
end
end
elseif query.bridge_args then -- Tested iphone SE 2 webview
if query.bridge_args.action_id and not query.error_code then
if onShare then
onShare()
end
end
end
end
end
end)
end
end
------------------------- Module functions
function service.setOnShare(newOnShare)
onShare = newOnShare
end
function service.setOnMe(newOnMe)
onMe = newOnMe
end
function service.init()
Runtime:addEventListener("system", handleNotifications)
facebook.init(listener)
end
function service.share(description)
description = description or "This is the description"
if isSimulator then
native.setActivityIndicator(true)
timer.performWithDelay(500, function()
native.setActivityIndicator(false)
if onShare then
onShare()
end
end)
else
if token then
local options = {
link = "https://www.zetosoft.com/landing/turbocrusher/",
description = description,
}
facebook.showDialog("link", options)
else
facebook.login()
end
end
end
return service
build.settings has everything in place. URL schemes, identifiers, plugins, permissions. As you can see, i had to add a system event listener to check applicationOpen
events to fire my own callback.