Local push notification and payload

Hello,
I’m sending a scheduled local push notification with some data in the payload (using https://github.com/defold/extension-push )
I’d like to read this data when the player opens the app by click on the push notification.

I’ve been looking into https://github.com/defold/extension-iac/ but I don’t see the listener being triggered when I open the app by clicking on the push notification.

Can anyone help?

Is this on Android or iOS?

IAC should give you any additional payload data used when the game is launched.

Yes I’m using Android.

The IAC listener never get fired.

I sent my local push notif like this

local payload = '{"data" : {"test" : "true"}}'
local message = "Let's test"
local notif_id, err = push.schedule(20, "This is a test", message, payload, { action = "get going" })

and I setup my listener in the bootstrap collection like this:

if iac then
			print("IAC is here")
			iac.set_listener(function (self, payload, type)
				print("IAC listener")
				pprint(payload)
				pprint(type)
				if type == iac.TYPE_INVOCATION then
					-- This was an invocation
					print(payload.origin) -- origin may be empty string if it could not be resolved
					print(payload.url)
				end
			end)
		end

But I dont’see anything when clicking the local push notif.
Am I doing anything wrong?

Not sure. @AGulev you have hands-on experience with push notifications right?

Yes.

iac is not related to push notifications at all. The thing you need is a listener you can setup using push.set_listener(). Please check the Push Notifications manual Defold Push notification documentation

I remember there are some issues in the module I reported here, but it was for a long time ago, not sure how it works now.

3 Likes