LevelUpKit is a Swift framework for adding gamification elements such as achievements, leaderboards, and progress tracking to your app. It aims to enhance user engagement by making the app more interactive and rewarding.
- Achievements: Create, manage, and display user achievements.
- Activity Achievements: Track specific user activities like consecutive logins or fast task completions.
- Leaderboard: Track user scores and display top users.
- Progressive Achievements: Track progress towards a long-term goal with milestones.
- Timed Achievements: Create achievements that must be completed within a specific time frame.
- Progress Tracking: Track user progress towards goals and provide feedback on their achievements.
- Animations: Show level-up and achievement animations for improved user experience.
To integrate LevelUpKit using Swift Package Manager:
- In Xcode, go to File > Add Packages.
- Enter the GitHub repository URL:
https://github.com/bks00jk/LevelUpKit
. - Select the version and add it to your project.
To integrate LevelUpKit using CocoaPods, add the following line to your Podfile
:
pod 'LevelUpKit', :git => 'https://github.com/bks00jk/LevelUpKit'
Here is a quick guide on how to use LevelUpKit in your project.
To create and unlock an achievement:
import LevelUpKit
let achievement = Achievement(title: "First Steps", description: "Complete the first task", iconName: "first_steps", points: 10)
achievement.unlock()
print(achievement.displayInfo())
To track user activities like consecutive logins:
let activityAchievement = ActivityAchievement(title: "Daily Streak", description: "Login for 5 consecutive days", iconName: "streak_icon", points: 20, activityType: .consecutiveLogin, target: 5)
activityAchievement.recordLogin()
To add users to a leaderboard and manage scores:
let leaderboard = Leaderboard()
leaderboard.addUser(username: "JohnDoe")
leaderboard.addPointsToUser(username: "JohnDoe", points: 50)
let topUsers = leaderboard.getTopUsers()
print(topUsers)
To create an achievement that tracks progress:
let progressiveAchievement = ProgressiveAchievement(title: "Marathon Runner", description: "Run 100 km", iconName: "marathon_icon", points: 50, goal: 100, milestones: [10, 25, 50, 75])
progressiveAchievement.updateProgress(by: 15)
To create an achievement that must be completed within a specific time period:
let timedAchievement = TimedAchievement(title: "Weekly Warrior", description: "Complete 5 tasks in a week", iconName: "weekly_icon", points: 30, period: .weekly, target: 5)
timedAchievement.completeTask()
To display achievement or level-up animations:
AnimationHelper.showAchievementAnimation(on: view, message: "Achievement Unlocked!")
AnimationHelper.showLevelUpAnimation(on: view, level: 2)
LevelUpKit is available under the MIT License. See the LICENSE file for more info.