Hi,
I have registered my App on OneSignal. I have added the OneSignal.lua and created pmessage.lua as suggested in the documents. Finally I have created a send_push rpc call and feed it with the needed parameters as described in the documents. The client successfully registers itself to OneSignal and puts the OneSignal Id to the users metadata correctly with the key “os_player_id”. I tried to send a push notification from the OneSignal dashboard and it worked.
But when I call the RPC from the client as below I receive the following error but I couldn’t figured it out what is going on.
I would be grateful if you would help me with this issue.
Mustafa
1-) the error I receive
ApiResponseException: System.Collections.Generic.Dictionary2[System.String,System.Object] Nakama.HttpRequestAdapter+d__6.MoveNext () (at <99ab1ffd513a481fae6067e64cfa51b3>:0) — End of stack trace from previous location where exception was thrown — System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <567df3e0919241ba98db88bec4c6696f>:0) System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <567df3e0919241ba98db88bec4c6696f>:0) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <567df3e0919241ba98db88bec4c6696f>:0) System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <567df3e0919241ba98db88bec4c6696f>:0) System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () (at <567df3e0919241ba98db88bec4c6696f>:0)
Nakama.ApiClient+d__52.MoveNext () (at <99ab1ffd513a481fae6067e64cfa51b3>:0)
…
2- ) Content of send_push RPC call file I uploaded to Nakama:
local nk = require(“nakama”)
local function send_push(context, payload)
local decoded = nk.json_decode(payload)
local user_ids = decoded.user_ids
local player_ids = {}
local users = nk.users_get_id(user_ids)
for _, u in ipairs(users)
do
table.insert(player_ids, u.metadata.os_player_id)
end
local contents = decoded.contents
local headings = decoded.headings
local included_segments = nil
local filters = nil
local params = {}
onesignal:create_notification(contents, headings, included_segments, filters, player_ids, params)
return payload
end
nk.register_rpc(send_push, “send_push”)
3- The way I call the RPC Call from the client code.
var payload = new Dictionary<string, object>
{
["user_ids"] = new List<string>() { "22f9e1fd-fae3-46c7-ae92-f0935c9897f7" },
["contents"] = new Dictionary<string, string>() { { "en", "MessageExample" } },
["headings"] = new Dictionary<string, string>() { { "en", "TitleExample" } }
};
await client.RpcAsync(session, "send_push", payload.ToJson());