Game Center Achievement Problems

Hello,
I am having a heck of a time trying to get an achievement working in my app. I followed as close to the tutorial as possible but I’m not having any luck. Here is some of my code…

gameNetwork.request( "loadAchievements", { listener=requestCallback } )  
local achievements = {}  
achievements.FirstApple = "com.appletest.FirstApple"  
  
local UserScore = 0  
  
local function onIncrementScore( event )  
 setUserScore( userScore+1 )  
  
 -- unlock achievements when specific tap requirement is met  
 if loggedIntoGC then  
 local message  
  
 if userScore == 1 then  
 print("working")  
 gameNetwork.request( "unlockAchievement", {  
 achievement = {  
 identifier=achievements["FirstApple"],  
 percentComplete=100,  
 showsCompletionBanner=true,  
 }  
 }); message = "You completed the \"Just One Tap\" achievement!"  
 end  
 end  
 end  
  

so the button isn’t working but when replaced the old OpenFeint code with this, it still wouldn’t work. I put in a print command to see if it was working but nothing. noMoreApples is called at the end of the level…

local achievements = {}  
achievements.FirstApple = "FirstApple" --The line here and above are called higher up in my code  
  
noMoreApples = function()   
local function achievement( event )  
 print("work")  
  
 if loggedIntoGC then  
 local message  
  
 if userScore == 1 then  
 print("work")  
 gameNetwork.request( "unlockAchievement", {  
 achievement = {  
 identifier=achievements["FirstApple"],  
 percentComplete=100,  
 showsCompletionBanner=true,  
 }  
 }); message = "You completed the \"Just One Tap\" achievement!"  
 end  
 end  
 end  

If you could help, that would be great!

Thanks,
Danny [import]uid: 59140 topic_id: 34869 reply_id: 334869[/import]

Hey, @Dannylego, I’m wondering if the problem is something to do with how you specify your identifier. Mine unlocks fine with the following:

gameNetwork.request( "unlockAchievement", {  
 achievement = {  
 identifier="com.mygame.myachievementname",  
 percentComplete=100,  
 showsCompletionBanner=true,  
 },  
})  

com.mygame.myachievementname is identical to the Achievement ID in iTC.

Naomi

Edit: Woops, I just looked at your code again, and I see you have specified [text]achievements.FirstApple = “com.appletest.FirstApple”[/text]. I wonder if you can get it to work with:

gameNetwork.request( "unlockAchievement", {  
 achievement = {  
 identifier=achievements.FirstApple,  
 percentComplete=100,  
 showsCompletionBanner=true,  
 },  
})  

I’m assuming gameNetwork.request is firing fine. If it isn’t firing at all, then you’ll need to debug why it isn’t…
[import]uid: 67217 topic_id: 34869 reply_id: 138636[/import]

Hey, @Dannylego, I’m wondering if the problem is something to do with how you specify your identifier. Mine unlocks fine with the following:

gameNetwork.request( "unlockAchievement", {  
 achievement = {  
 identifier="com.mygame.myachievementname",  
 percentComplete=100,  
 showsCompletionBanner=true,  
 },  
})  

com.mygame.myachievementname is identical to the Achievement ID in iTC.

Naomi

Edit: Woops, I just looked at your code again, and I see you have specified [text]achievements.FirstApple = “com.appletest.FirstApple”[/text]. I wonder if you can get it to work with:

gameNetwork.request( "unlockAchievement", {  
 achievement = {  
 identifier=achievements.FirstApple,  
 percentComplete=100,  
 showsCompletionBanner=true,  
 },  
})  

I’m assuming gameNetwork.request is firing fine. If it isn’t firing at all, then you’ll need to debug why it isn’t…
[import]uid: 67217 topic_id: 34869 reply_id: 138636[/import]