gotoScene after press on notification

So i’m trying to go to a certain Scene after the notification is clicked, but it seems that it’s always going to main.lua.

Here’s what I have. This code is not in the main.lua but in another scene where the notification can be set. How can this be done?

local notiOptions = { alert = row.baslik, badge = 1, sound = "alarm.mp3", custom = { scene = "scene2" } } local onNotification = function( event ) print( event.name ) if ( event.custom ) then local options = { isModal = true, params = { id = myApp.id, baslik = myApp.baslik } } -- SHOW SCENE AFTER PRESS composer.removeHidden() composer.gotoScene( event.custom.scene, options ) end end Runtime:addEventListener( "notification", onNotification )

if ( launchArgs and launchArgs.notification ) then

    onNotification( launchArgs.notification )

end

Can you print out the value of your event.custom table?

Rob

Nope, nothing. I always get a nil value returned in the console. This is was I printed. I tired printing the event.custom and using prettify. With the json I got a table list with all the values, but whenever I wanna print ‘event.custom’ with it, it always shows me nil. I tried to change to ‘gotoScene’ to scene2 but didnt do the trick either.

print( event.custom ) print( json.prettify( notiOptions ) )

QUESTION: Does the onNotification function need to be run from the main.lua? Because now it’s not. 

Try printing out the whole event table.

Do you mean this?

print( event.alert ) print( event.badge) print( event.sound ) print( event.custom.scene )

I always get nil values. I only get values if I use json prettify( notiOptions ). I i use prettify(event.custom.scene) I get a nil value

print( json.prettify( event ) )

Doesnt print anything related to the custom table. What do I need to look for exactly?

Sounds like you’re not getting the custom table passed to your app. Are you sure it’s being sent by your push service correctly?

Its a local notificaiton actually, not a push one. Might that be the problem? If I simply put gotoscene(“scene2”) in there, it wont work either.

I don’t believe local notifications have a custom table.

Rob

I see. I followed the docs and that one has a custom tho. Is there another way to use it? To go to a scene when pressed on local notification?

Given that you set the notifications you should know what to do when they trigger.

Rob

Can you print out the value of your event.custom table?

Rob

Nope, nothing. I always get a nil value returned in the console. This is was I printed. I tired printing the event.custom and using prettify. With the json I got a table list with all the values, but whenever I wanna print ‘event.custom’ with it, it always shows me nil. I tried to change to ‘gotoScene’ to scene2 but didnt do the trick either.

print( event.custom ) print( json.prettify( notiOptions ) )

QUESTION: Does the onNotification function need to be run from the main.lua? Because now it’s not. 

Try printing out the whole event table.

Do you mean this?

print( event.alert ) print( event.badge) print( event.sound ) print( event.custom.scene )

I always get nil values. I only get values if I use json prettify( notiOptions ). I i use prettify(event.custom.scene) I get a nil value

print( json.prettify( event ) )

Doesnt print anything related to the custom table. What do I need to look for exactly?

Sounds like you’re not getting the custom table passed to your app. Are you sure it’s being sent by your push service correctly?

Its a local notificaiton actually, not a push one. Might that be the problem? If I simply put gotoscene(“scene2”) in there, it wont work either.