/** * Report an achievement with a percentComplete * * @param identifier * @param percentComplete */ public void reportAchievement(String identifier, double percentComplete) { // If player is not authenticated, do nothing if (!GKLocalPlayer.getLocalPlayer().isAuthenticated()) { listener.achievementReportFailed(); return; } GKAchievement achievement = new GKAchievement(identifier); achievement.setPercentComplete(percentComplete); achievement.setShowsCompletionBanner(true); // If iOS version is 6 or more we use the new method if (getIosVersion() >= IOS_6) { // Create an array with the achievement NSArray<NSObject> achievements = new NSArray<NSObject>(achievement); GKAchievement.reportAchievements( achievements, new VoidNSErrorBlock() { @Override public void invoke(NSError error) { if (error != null) { listener.achievementReportFailed(); } else { listener.achievementReportCompleted(); } } }); } else { // If iOS version is 5 or less we use the deprecated method achievement.reportAchievement( new VoidNSErrorBlock() { @Override public void invoke(NSError error) { if (error != null) { listener.achievementReportFailed(); } else { listener.achievementReportCompleted(); } } }); } }