Anyway to check if a particular app is installed on device?

Started by
ksan
Jun 08 2014 05:49 PM

ksan

[GLOBAL: userInfoPane.html]

ksan

Corona Geek

2,795 posts

Corona SDK

08 June 2014 - 05:49 PM

Hi,

I have a quick question. Is there anyway to find out if a particular app is installed on device? I'm thinking of adding some cross promotion elements to some of my apps but I would like to trigger this only when I know that the user does not have my other app installed on his/her device. If the app is installed the cross-promotion would be very annoying very quickly. Any ideas?

In the app that you are using to promote your other app you could do something like this:

local platform = system.getInfo( "platformName" )
local storestring = system.getInfo( "targetAppStore")
local appinstalled = false
local function getappfromstore()
local options =
{
iOSAppId = "xxxxxxxxxx",
nookAppEAN = "xxxxxxxxxxxxxxxx",
androidAppPackageName = "com.icyspark.bargainhunter",
supportedAndroidStores = {storestring},
}
native.showPopup("appStore", options)
end
if platform == "Android" then
local appIcon = display.newImage("android.app.icon://com.icyspark.bargainhunter",160,-200)
if appIcon then
-- App is installed.
display.remove(appIcon)
appIcon = nil
appinstalled = true
else
-- App is not installed.
appinstalled = false
end
local otherappbutton = display.newRect(sceneGroup,160,240,50,50)
otherappbutton:setFillColor(0.5)
local function clickbanner(self,e)
-- button listener for when you press the button to either load other app or get it from store
if e.phase == "began" then
self:setFillColor(0.88)
elseif e.phase == "ended" then
self:setFillColor(0.5)
if platform == "Android" then
if appinstalled == true then
if not system.openURL("bargainhunter://") then
getappfromstore()
--print("App Not Installed")
end
else
getappfromstore()
end
elseif platform == "iPhone OS" then
if not system.openURL("bargainhunter://") then
getappfromstore()
end
end
end
return true
end
otherappbutton.touch = clickbanner
otherappbutton:addEventListener("touch")