native.showWebPopup not showing when user goes back to menu screen

I have Director working with 5 screens, one of them being the home screen (menu.lua). Each screen has a native.showWebPopup on it, including Home.

The native.showWebPopup on the home screen loads fine when the app loads, and on all other screens as well. They work fine to click back and forth between the screens.

But when the user goes back to the home screen (menu.lua) from any of the other screens, the native.showWebPopup doesn’t load.

My menu.lua code is below:

module(..., package.seeall)  
  
function new()  
 local localGroup = display.newGroup()  
 --\> This is how we start every single file or "screen" in our folder, except for main.lua  
 -- and director.lua  
 --\> director.lua is NEVER modified, while only one line in main.lua changes, described in that file  
------------------------------------------------------------------------------  
------------------------------------------------------------------------------  
local background = display.newImage ("whitebackground.png")  
localGroup:insert(background)  
--\> This sets the background  
  
local titlebar = display.newImageRect ("titlebar.png", 1135, 102)  
localGroup:insert(titlebar)  
titlebar.y = 22   
--\> This sets the titlebar  
  
local title = display.newImageRect ("title.png", 200, 42)  
localGroup:insert(title)  
title.x = 160  
title.y = 40  
--\> This sets the title  
  
local navbar = display.newImageRect ("navbarbg.png", 1148, 120)  
localGroup:insert(navbar)  
navbar.y = 462  
--\> This sets the navbar  
  
local eatbutton = display.newImageRect ("eatbutton.png", 94, 45)  
eatbutton.x = 60  
eatbutton.y = 390  
localGroup:insert(eatbutton)  
  
local dobutton = display.newImageRect ("dobutton.png", 94, 45)  
dobutton.x = 160  
dobutton.y = 390  
localGroup:insert(dobutton)  
  
local shopbutton = display.newImageRect ("shopbutton.png", 94, 45)  
shopbutton.x = 260  
shopbutton.y = 390  
localGroup:insert(shopbutton)  
--\> This places our three buttons  
  
local function pressEat (event)  
if event.phase == "ended" then  
director:changeScene ("eat")  
end  
end  
  
eatbutton:addEventListener ("touch", pressEat)  
  
local function pressDo (event)  
if event.phase == "ended" then  
director:changeScene ("do")  
end  
end  
  
dobutton:addEventListener ("touch", pressDo)  
  
local function pressShop (event)  
if event.phase == "ended" then  
director:changeScene ("shop")  
end  
end  
  
shopbutton:addEventListener ("touch", pressShop)  
--\> This adds the functions and listeners to each button  
local iconHome = display.newImageRect ("icon\_home.png", 58, 30)  
iconHome.x = 38  
iconHome.y = 457  
localGroup:insert(iconHome)  
--\> This places our "home" button, which will do nothing here on the home screen  
  
local iconEvents = display.newImageRect ("icon\_events.png", 62, 30)  
iconEvents.x = 101  
iconEvents.y = 457  
localGroup:insert(iconEvents)  
  
local iconDeals = display.newImageRect ("icon\_deals.png", 58, 30)  
iconDeals.x = 163  
iconDeals.y = 457  
localGroup:insert(iconDeals)  
  
local iconExplore = display.newImageRect ("icon\_explore.png", 68, 30)  
iconExplore.x = 228  
iconExplore.y = 457  
localGroup:insert(iconExplore)  
  
local iconInfo = display.newImageRect ("icon\_info.png", 46, 30)  
iconInfo.x = 286  
iconInfo.y = 457  
localGroup:insert(iconInfo)  
--\> This places bottom navs  
local function pressEvents (event)  
if event.phase == "ended" then  
director:changeScene ("events")  
end  
end  
iconEvents:addEventListener ("touch", pressEvents)  
  
local function pressDeals (event)  
if event.phase == "ended" then  
director:changeScene ("deals")  
end  
end  
iconDeals:addEventListener ("touch", pressDeals)  
  
local function pressExplore (event)  
if event.phase == "ended" then  
director:changeScene ("explore")  
end  
end  
iconExplore:addEventListener ("touch", pressExplore)  
  
local function pressInfo (event)  
if event.phase == "ended" then  
director:changeScene ("info")  
end  
end  
iconInfo:addEventListener ("touch", pressInfo)  
--\> This adds the functions and listeners to each buttom nav button (Except home)  
------------------------------------------------------------------------------  
native.showWebPopup( -1, 76, 320, 285, "http://fingerlakesapp.com/app" )  
 return localGroup  
end  

And an example from another screen (deals.lua):

[code]
module(…, package.seeall)

function new()
local localGroup = display.newGroup()
–> This is how we start every single file or “screen” in our folder, except for main.lua
– and director.lua
–> director.lua is NEVER modified, while only one line in main.lua changes, described in that file


local background = display.newImage (“whitebackground.png”)
localGroup:insert(background)
–> This sets the background

local titlebar = display.newImageRect (“titlebar.png”, 1135, 102)
localGroup:insert(titlebar)
titlebar.y = 22
–> This sets the titlebar

local title = display.newImageRect (“title.png”, 200, 42)
localGroup:insert(title)
title.x = 160
title.y = 40
–> This sets the title

local navbar = display.newImageRect (“navbarbg.png”, 1148, 120)

localGroup:insert(navbar)
navbar.y = 462
–> This sets the navbar

local iconHome = display.newImageRect (“icon_home.png”, 58, 30)
iconHome.x = 38
iconHome.y = 457
localGroup:insert(iconHome)
–> This places our “back home” button

local function pressBack (event)
if event.phase == “ended” then
director:changeScene (“menu”)
native.cancelWebPopup()
end
end

iconHome:addEventListener (“touch”, pressBack)
–> This adds the function and listener to the “back” button

local iconEvents = display.newImageRect (“icon_events.png”, 62, 30)
iconEvents.x = 101
iconEvents.y = 457
localGroup:insert(iconEvents)

local iconDeals = display.newImageRect (“icon_deals.png”, 58, 30)
iconDeals.x = 163
iconDeals.y = 457
localGroup:insert(iconDeals)

local iconExplore = display.newImageRect (“icon_explore.png”, 68, 30)
iconExplore.x = 228
iconExplore.y = 457
localGroup:insert(iconExplore)

local iconInfo = display.newImageRect (“icon_info.png”, 46, 30)
iconInfo.x = 286
iconInfo.y = 457
localGroup:insert(iconInfo)
–> This places bottom navs
local function pressEvents (event)
if event.phase == “ended” then
director:changeScene (“events”)
end
end
iconEvents:addEventListener (“touch”, pressEvents)

local function pressDeals (event)
if event.phase == “ended” then
director:changeScene (“deals”)
end
end
iconDeals:addEventListener (“touch”, pressDeals)

local function pressExplore (event)
if event.phase == “ended” then
director:changeScene (“explore”)
end
end
iconExplore:addEventListener (“touch”, pressExplore)

local function pressInfo (event)
if event.phase == “ended” then
director:changeScene (“info”)
end
end
iconInfo:addEventListener (“touch”, pressInfo)
–> This adds the functions and listeners to each buttom nav button (Except home)

native.showWebPopup( -1, 76, 320, 340, “http://fingerlakesapp.com/app/deals” )
return localGroup
end
[/code] [import]uid: 101670 topic_id: 28652 reply_id: 328652[/import]

Any help with this? I’m sure it’s 100% noobish and something I’ve just done plain wrong. [import]uid: 101670 topic_id: 28652 reply_id: 116086[/import]

I just skimmed this but are you closing the web popup or just opening it and then leaving it? If you aren’t closing it on scene change I would imagine that may be the culprit. [import]uid: 52491 topic_id: 28652 reply_id: 116206[/import]

I think I’m closing it! :slight_smile:

There is this:

local function pressBack (event)  
if event.phase == "ended" then  
director:changeScene ("menu")  
native.cancelWebPopup()  
end  
end  
   
iconHome:addEventListener ("touch", pressBack)  
--\> This adds the function and listener to the "back" button  

Which I think closes the WebPopup on scene change (going back to the home screen).

Should I be doing something else somewhere else? [import]uid: 101670 topic_id: 28652 reply_id: 116758[/import]

That *should* be OK but just out of interest can you try moving the cancel to just above where you change scene - maybe even try a timer on the director line - just to test?

Eg;
[lua]local function pressBack (event)
if event.phase == “ended” then
native.cancelWebPopup()
timer.performWithDelay(1000, function() director:changeScene (“menu”) end, 1)
end
end

iconHome:addEventListener (“touch”, pressBack)[/lua]

Can you let me know if that helps at all, please? (I know you wouldn’t use a 1 second delay in a live app but am just curious.)

Peach :slight_smile: [import]uid: 52491 topic_id: 28652 reply_id: 116840[/import]

Ah yes! The timer does the trick. Thanks so much, Peach. [import]uid: 101670 topic_id: 28652 reply_id: 116851[/import]

Oh, excellent - FYI you can probably put that way, way lower than 1000 milliseconds.

Peach :slight_smile: [import]uid: 52491 topic_id: 28652 reply_id: 116982[/import]

Hi Peach

I have an issue, please look into this, native.showWebPopup(0,40,display.contentWidth,display.ContentHeight*0.9,“https://twitter.com?scXXXX”)

This will not show on iphone4 and any of ios devices. But it is working on Android devices, Why not on ios devices? Please help me… [import]uid: 172535 topic_id: 28652 reply_id: 133982[/import]

Hello,
The “c” in “display.contentHeight” should be lowercase, not uppercase as you have it. Try changing that and testing it on iOS. It might be another issue, but try this first.

Regards,
Brent [import]uid: 200026 topic_id: 28652 reply_id: 133988[/import]

Hi - I have a director in my folder and I want to use pop up for the selection of level and play method but it did not work out. Can someone help, pls?

Keat [import]uid: 27142 topic_id: 28652 reply_id: 134009[/import]

Hi Brent,

Thanks, I corrected it and when I go to facebook link, after login the pop-up is removing in ios device but working on simulator. why so? Suggest me
Thaks in Advance [import]uid: 172535 topic_id: 28652 reply_id: 134015[/import]

Hi @hemanth,
Can you post some of your code related to where you add the popup and then try to remove it?

Please put the code between the formatted code tags, so we can read it easier.

<code>

</code>

Brent
[import]uid: 200026 topic_id: 28652 reply_id: 134047[/import]

Hi Peach

I have an issue, please look into this, native.showWebPopup(0,40,display.contentWidth,display.ContentHeight*0.9,“https://twitter.com?scXXXX”)

This will not show on iphone4 and any of ios devices. But it is working on Android devices, Why not on ios devices? Please help me… [import]uid: 172535 topic_id: 28652 reply_id: 133982[/import]

Hello,
The “c” in “display.contentHeight” should be lowercase, not uppercase as you have it. Try changing that and testing it on iOS. It might be another issue, but try this first.

Regards,
Brent [import]uid: 200026 topic_id: 28652 reply_id: 133988[/import]

Hi - I have a director in my folder and I want to use pop up for the selection of level and play method but it did not work out. Can someone help, pls?

Keat [import]uid: 27142 topic_id: 28652 reply_id: 134009[/import]

Hi Brent,

Thanks, I corrected it and when I go to facebook link, after login the pop-up is removing in ios device but working on simulator. why so? Suggest me
Thaks in Advance [import]uid: 172535 topic_id: 28652 reply_id: 134015[/import]

Hi @hemanth,
Can you post some of your code related to where you add the popup and then try to remove it?

Please put the code between the formatted code tags, so we can read it easier.

<code>

</code>

Brent
[import]uid: 200026 topic_id: 28652 reply_id: 134047[/import]