A Fuse Powered Company

Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Anyway to check if a particular app is installed on device?
Started by ksan Jun 08 2014 05:49 PM

- - - - -
3 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,779 posts
  • Jedi

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



[TOPIC: post.html]
#2

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,779 posts
  • Jedi

Any ideas? Thanks in advance for your input.



[TOPIC: post.html]
#3

Icy Spark

[GLOBAL: userInfoPane.html]
Icy Spark
  • Pro
  • PipPipPipPipPipPip
  • 243 posts
  • Jedi

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:

 

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.
      },
   },
 
 
}

 

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

 

I hope this helps get you started.



[TOPIC: post.html]
#4

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,779 posts
  • Jedi

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.!!!  :)




[topic_controls]
[/topic_controls]