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

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?

Thanks much for sharing.

Regards,

Kerem

Any ideas? Thanks in advance for your input.

Hi ksan, yes this is feasible on both android and iOS.

Here’s what you need to do:

On the app that you want to promote set your build settings to something like this:

[lua]

settings = {

orientation = {

default = “portrait”,

supported = { “portrait”, “portraitUpsideDown”}

},

iphone = {

plist = {

–UIStatusBarHidden = false,

–UIPrerenderedIcon = true, – set to false for “shine” overlay

CFBundleIconFile = “Icon.png”,

                     CFBundleIconFiles = {       

“Icon.png”,

“Icon@2x.png”,

“Icon-40.png”,

“Icon-40@2x.png”,

“Icon-60.png”,

“Icon-60@2x.png”,

“Icon-72.png”,

“Icon-72@2x.png”,

“Icon-76.png”,

“Icon-76@2x.png”,

“Icon-Small-50.png”,

“Icon-Small-50@2x.png”,

“Icon-Small.png”,

“Icon-Small@2x.png”,

“Icon-Small-40.png”,

“Icon-Small-40@2x.png”

},

UIStatusBarHidden = true,

UIPrerenderedIcon = true, – set to false for “shine” overlay

UIAppFonts =

{

“HelveticaNeue-Light.ttf”,

},

UIApplicationExitsOnSuspend = false, – uncomment to quit app on suspend

CFBundleURLTypes = {

{

CFBundleURLSchemes =

{

–“fb1234567890”, – example scheme for facebook

“bargainhunter”, – bargain hunter url scheme

},

},

},

}

},

plugins =

{

– key is the name passed to Lua’s ‘require()’

[“CoronaProvider.analytics.flurry”] =

{

– required

publisherId = “com.coronalabs”,

},

},

– Android permissions

androidPermissions = {

  “android.permission.INTERNET”,

  },

android =

   {

      intentFilters =

      {

         {

            label = “Bargain Hunter”,

            actions = { “android.intent.action.VIEW” },

            categories =

            {

               “android.intent.category.DEFAULT”,

               “android.intent.category.BROWSABLE”,

            },

            data = { scheme = “bargainhunter” },

         },

         – You can add more intent filters here.

      },

   },

}[/lua]

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

[lua]

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”)

[/lua]

I hope this helps get you started.

This is amazing!!! Thank you so very much for sharing this extensive code with me and all folks on this forum. I am very grateful. I will use this right away. Most appreciated.!!!  :slight_smile:

Any ideas? Thanks in advance for your input.

Hi ksan, yes this is feasible on both android and iOS.

Here’s what you need to do:

On the app that you want to promote set your build settings to something like this:

[lua]

settings = {

orientation = {

default = “portrait”,

supported = { “portrait”, “portraitUpsideDown”}

},

iphone = {

plist = {

–UIStatusBarHidden = false,

–UIPrerenderedIcon = true, – set to false for “shine” overlay

CFBundleIconFile = “Icon.png”,

                     CFBundleIconFiles = {       

“Icon.png”,

“Icon@2x.png”,

“Icon-40.png”,

“Icon-40@2x.png”,

“Icon-60.png”,

“Icon-60@2x.png”,

“Icon-72.png”,

“Icon-72@2x.png”,

“Icon-76.png”,

“Icon-76@2x.png”,

“Icon-Small-50.png”,

“Icon-Small-50@2x.png”,

“Icon-Small.png”,

“Icon-Small@2x.png”,

“Icon-Small-40.png”,

“Icon-Small-40@2x.png”

},

UIStatusBarHidden = true,

UIPrerenderedIcon = true, – set to false for “shine” overlay

UIAppFonts =

{

“HelveticaNeue-Light.ttf”,

},

UIApplicationExitsOnSuspend = false, – uncomment to quit app on suspend

CFBundleURLTypes = {

{

CFBundleURLSchemes =

{

–“fb1234567890”, – example scheme for facebook

“bargainhunter”, – bargain hunter url scheme

},

},

},

}

},

plugins =

{

– key is the name passed to Lua’s ‘require()’

[“CoronaProvider.analytics.flurry”] =

{

– required

publisherId = “com.coronalabs”,

},

},

– Android permissions

androidPermissions = {

  “android.permission.INTERNET”,

  },

android =

   {

      intentFilters =

      {

         {

            label = “Bargain Hunter”,

            actions = { “android.intent.action.VIEW” },

            categories =

            {

               “android.intent.category.DEFAULT”,

               “android.intent.category.BROWSABLE”,

            },

            data = { scheme = “bargainhunter” },

         },

         – You can add more intent filters here.

      },

   },

}[/lua]

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

[lua]

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”)

[/lua]

I hope this helps get you started.

This is amazing!!! Thank you so very much for sharing this extensive code with me and all folks on this forum. I am very grateful. I will use this right away. Most appreciated.!!!  :slight_smile: