Group members

  • Xavier Bohin (xaboh17)
  • Anders Christoffersen (andec17)
  • Margaux Dang (madan17)

Introduction

  • Context

In order to fulfill the project of iOS Programming, we had to realize a project with different constraints. The project must be physical play or game and have to use at least, one sensor excluding touch.

Moreover, for us, the goal was also to learn about the language in general and how we can build an app. The second personal goal was also to learn about “secret” features of iOS (by “secret”, we mean subject which needs deeper analysis) and surrounding materials. In other words, our main goal is to improve ourselves in iOS Programming from the syntax to the design passing by databases, sensors…etc.

With all of those pre-requisites, we decided to build a project mixing game and physical play (especially sport), which will use accelerometer, external Bluetooth sensor and external database. We know that it can be more complicated, but our first goal was to understand and learn how does it works and create a useful application.

 

  • The idea

The idea is very simple : motive people to do more exercises. In order to motivate them, we decide to mix sport but also fun.To do this, the user has to make some jumps and then, according to how much jumps the user have done and altitude, the user can have different way of playing our game.

For example: The more he/she did jumps, the more he/she will have jumps to the game.

We decide to mix 2 parts: Game and Sport in order to motivate users as much as possible.

Moreover, for more motivation, we include some social aspects: allow them to compete with friends with the possibility to share results on social media. To understand well, we can find a schema just below:

 

  • Current problem

This subject is important because nowadays few people practice sports. Indeed, according to a french website, L’internaute, only 30% do sport daily. Other persons have never practiced exercises or only once a month (or once a year!).

There is lot of reasons, but the main reason is that they don’t have enough time, but also because they haven’t motivation or simply because membership to local gym is too expensive.

Even if this problem don’t really worry people, our goal is to solve this problem because according to the WHO (World Health Organization), the health recommendation is to do, at least, 10 000 steps a day. But actually, approximately 75% of the population don’t do it.

But, what is the consequence of don’t do enough sports ?

According to a scientific journal (We can find it here:  article) published by the New York Times in 2016, low physical activity causes death as the same level than tobacco.Moreover, for non-sport enthusiasts, there is 21% more risk of premature death

So that’s why we want to act !  

 

  • Our solution

Moreover, if people don’t feel concerned by sport, it is because they are interesting by playing on their computers or phones. Indeed, according to a french website Femininbio,  63% of the 18-24 years recognize that the impact of screens has consequences on their physical activity.

Nowadays, in a “connected” world, we have to implement digital and numeric solutions and that’s why our solution is to mixt a game app with sport.

Our mobile application is based on  the reward system which our motto “After effort comes comfort”. So, in our case, the effort corresponds to jumps and the reward/comfort is the possibility to play to the game.

We also want to motivate them by an attractive design, possibility to access to statistics in order to follow its evolution and finally, the app allows also to share the results with friends by any kind messaging applications and compete with them.

Thereby, our application uses 3 systems: reward, competition, and self improvement.

 

  • Common platforms

If there are actually many solutions that developed physical activities, any application proposes some motivating and sustainable solutions so we think our idea is important to permit to people to do fast exercises at home without money and to continue to do it regularly.

(Note that 15 min of jumping is equivalent to 30 min of footing, so it will be faster).

But even if a lot of companies try to fix this current problem, even big companies like Microsoft or Nike, the results are not satisfying. Indeed, most of the time, people download the application, try it for 1 or 2 weeks and then, stop using it and finally delete it.

Actually, there are no solutions which are similar to “JumpIn” because our idea is the merging between 2 existing ideas:

  • Physical activities applications:

It exists a lot (lot, lot) of physical activities like Runstastic, SST Sport Tracker, Strava… etc. Those applications can displays very precise statistics and track different activities (running, biking, walking…etc.).

From those ideas, we decide to build an application which can track jumps and after, as screens below, displays statistics and history.

Moreover, there aren’t physical activities applications dedicated to jumping, but there are some close applications which include jumping exercises like “Freeletics”. Freeletics works as a coach, so this app permit to give some instructions and the user have to follow the coach.

So we keep the idea of Runstastic: tracking activities and the concept of Freeletics which allow to count jumps.

  • Game applications:

For the applications, we decide to inspire the idea of Mega Jump or Doodle Jump. Those applications are very famous and very appreciated. Moreover, there are very closed to the physical activities.

Mega Jump and Doodle Jump are apps which are playable with touch. The user incarnates a player and he/she have to climb the upper as possible. To do this, the player can jump on platforms (breakable or not) and can have some jump boosts by catching stars.

To conclude, our application is “2 in 1” application. We use some existing applications and we decide to improve them.

 

  • Our objectives

More than learning iOS Programming, our main objective for the application is to create a functional application first. This application has to be intuitive and very easy to use. Indeed, our goal is to make the life easier for the user.

Moreover, we want to convince people to make some activities: for their health and also their pleasure. It is very important for us that the user feels some happiness when he/she does activities because in most of the app, when the user download it, it is a way of salving their consciences.

So, our second objective is to build a motivating application, we want that the user uses the app by desire and not because it is a requirement, “I have to do sport for my health”, “It’s good to do exercises”… etc.

Finally, if the 2 previous objectives are achieved and the application is fully completed and optimized, our final goal is to make it available for everyone in the App Store. Subsequently, we want that the application is useful and use by at least 100 regular users.

 

Methods and materials

  • Materials

First of all, we had some materials for realize our project:

  • XCode (Version 9.1)
  • Swift 4.0
  • BLE Bluetooth Sensor 4.0

Moreover, we need, at least, one iPhone, in order to use the accelerometer because the simulator doesn’t run it.

  • Methods

First of all, at the beginning, we decided to make a Brainstorming in order to find our idea and discuss about it. Then, when the idea was chosen, we would like to consolidate it. From this brainstorming, we, then, find out a conceptual model for our application. (What should the application be able to do?, how it will change the user’s life?, What is the name?…etc.).

 

The idea now is solid and we had to structure it!

In that way, we decide to create simple prototypes:

We make a “paper” sketches at the beginning and then synthesize it on a numerical version on Balsamiq. Balsamiq is a computer software which allows to create application prototypes with navigation between different views. It is a good way to visualize what the application will look like. Then, before beginning to build our application, we tested the prototypes with potential users in order to analyse feedbacks, know if the idea can be useful, and if the user have a list of demands.

 

Now, it’s time to implement it on Xcode!

First of all, we create a new project, at the beginning, we put in settings Swift Language and Single View App (But we will see after that Games App is better). Then, we build a navigational digital prototype. For starting, we create on the storyboard the different views and on each, we put the buttons, labels, text fields…etc. Then, from the storyboard, we create the links between all the views.

At the beginning, we created only few views and let some blank views (like games and statistics).Blank views are voluntary let blanks because we consider them as difficult. After, creating the majority of the views, we decide to do a second evaluation nearby the potential customers.

Then, we decide to split our work in two parts :

  • The first part is dedicated to the Bluetooth
  • The other is dedicated to the rest:
    • Implementation of the game
    • Social part
    • Statistics
    • Registration/Login
    • Designing

Then, step to step, we build separately the app :

For the implementation part:

  1. First of all, we build all the views and all the elements on the views (buttons, labels, text fields…etc).
  2. Then, we implement the database. We decide to use Firebase because it is well documented, easy to use and there is a part of authentication and real time database. So, in one hand, we focus on the authentication and consequently, we added 2 new views : those for the registration and login. (At the beginning, we hadn’t planned to implement them).
  3. After this, we implement the game by following a tutorial (can see it on resources).
  4. We modify the information displaying the weight and high (saved on Firebase) and with the possibility to modify those parameters.
  5. Then, we focus on the jumping part. So, at the beginning, we estimate the number of jumps, calories, duration and altitude. We try to simulate a session and to save it on Firebase and print this session.
  6. We simulate a second session and we shift the last session to session 1 and the previous session to session 2.
  7. Simulate for more than 2 sessions to see if the session is well shifted.
  8. After this, we replace the estimated values put in step 5). So to do this, we implement a timer and calculate the calories with a formula we find on Internet for jumping rope. (Source: https://www.regivia.com)
    Calories (in kCal) = (MET * 3,5 * weight)/200*duration with MET = 7,5
  9. Then, with all the sessions saved in Firebase, we use the Framework created by YiChen Zhou called “PNChartSwift”.
  10. Finally,we make the game constraints according to how many jumps the user made.
  11. Last but not least, we implement the possibility to share on social media, message, emails, etc…

For the Bluetooth part:

  1. We, first of all, look at some tutorials and then, we reproduce it. This tutorial is used to explore the Bluetooth devices around. Then, we can scan the devices, connected to peripheral and discover it. We can then, find all the services available, and especially “accelerometer data”.
  2. Then, thanks to Anders Bogild’s project in order to print accelerometer data on xCode console.
  3. We merge this project with the actual one.
  4. According to accelerometer data, we try to jump and see the changes of those data when we jump and then add +1 to the jump label.

Then, according to previous evaluations, some people advise us to use the accelerometer because lot of people don’t want to use all the time the sensor because it is more binding.

So, we add a bar tab controller in order to switch between external sensor view and accelerometer data view. In the accelerometer one, we can retrieve accelerometer data of the mobile phone with the “Core Motion” package. Like the Bluetooth part, we look at values and observe changes to increase the number of jumps.

Finally, we modify a little bit the design things and details, like hide the keyboard when the user click on the screen.

And then, test the application again and again in order to refine the it. When, we correct all the errors, we decide to ask some evaluations from external person and correct the last errors.

 

Results

  • Methods’ results

From the first brainstorming, we find directly the idea to merge physical activities with game, but the conceptual model was a little bit vague at the beginning. But steps after steps, we find a structured model:

  • The name app is “Jump In”
  • The logo is :

  • We find our main idea (explain in the part “The idea” and “Our solution)
  • We also compare similar apps
  • And finally, we find our main target :

 

Then, we draw some simple prototypes. The first one made on “paper” in order to analyse the desire of each member of the group to be sure that everybody have the same idea and in order to begin well the project and everybody goes in the same direction.

Below, you can find it :

To synthesize it, we decide to create the same prototype in numeric version in Balsamiq, we can find it here (Google Drive) if you want.

These prototypes allow us to poll the potential users. We created a Google Form and the answers was very positive. 71,4% of the participants are convinced that the application will be useful for them and for the sport and 85,7% think that the app is easy to use regarding to the Balsamiq version.

After this, in order to go more in deep in the evaluation, we build our navigational digital prototype on Xcode with the storyboard – navigational digital prototype which allows us to make a second evaluation.

From this, the results were also positive, but 2 remarks draw our attention : the game is a little bit “buggy” and that it is nice if we implement a solution which works without external sensor.

Then, we implement all the applications and finally we can find some screen results just below:

 

  • Code

To understand well how we did, you can find some pieces of code :

  • Counting the jumps
    • Accelerometer
var motionManager = CMMotionManager()
//1
motionManager.accelerometerUpdateInterval = 0.1

//2
motionManager.startAccelerometerUpdates(to: OperationQueue.current!) { (data, error) in
  if let myData = data {
        let xvalue: Double = myData.acceleration.x
        let yvalue: Double = myData.acceleration.y
        let zvalue: Double = myData.acceleration.z
        var Avalue: Double = 0            
        Avalue = sqrt(xvalue*xvalue + yvalue*yvalue + zvalue*zvalue)
                    
//3                   
        if (Avalue > 4.2 && self.count == 0){
            self.jump = self.jump + 1
            self.count = 1
        }
        if ( Avalue < 4.2 ){
            self.count = 0
        }
                    
//4 
       self.realjump = (Int)(self.jump)
       self.jumpText.text = (String)(self.realjump)
   }
}

First of all, we have to import the CoreMotion package and then initiliaze a core manager.

//1 : At the beginning, we set the interval of the accelerometer. We put it very little in order to have more accurate values. 

//2 : Then, we start the accelerometer and we stop the data and especially the “Avalue”.

//3 : After try to jump many time, we observe that when the Avalue is greater than 4.2, it corresponds to a jump. 

//4 : And finally, we modify the text label value by +1 or +0.

(Note: We use the same method for the Bluetooth sensor but with a different threshold).

  • Bar chart
//1
let barChart = PNBarChart(frame: CGRect(x: 0, y: 50, width: 320, height: 200))
barChart.backgroundColor = UIColor.clear
barChart.animationType = .Waterfall
barChart.labelMarginTop = 5.0

//2
barChart.xLabels = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10" ]
barChart.yValues = [CGFloat(sess1Double!),CGFloat(sess2Double!),CGFloat(sess3Double!),CGFloat(sess4Double!),CGFloat(sess5Double!),CGFloat(sess6Double!),CGFloat(sess7Double!),CGFloat(sess8Double!),CGFloat(sess9Double!), CGFloat(sess10Double!)]

//3 
barChart.strokeChart()
barChart.center = self.view.center
self.view.addSubview(barChart)

//1 : We create the bar chart thanks to PNBarChart Framework and we fix all the design (background, animations, size).

//2 : We set the easting and orderly of the chart according to the activities (jumps, calories, duration) and our sessions.

//3 : Finally, we add the bar chart to the view.

  • Firebase part
    • Authentification
//Create user
Auth.auth().createUser(withEmail: username, password: password, completion: { user, error in 
     
     //Errors
     if let firebaseError = error {
        self.createAlert(title: "Error", message: firebaseError.localizedDescription)
        return
     }
})
//Sign in
if let username = usernameInput.text, let password = passwordInput.text {
   Auth.auth().signIn(withEmail: username, password: password, completion: { user, error in
          
         //Error
         if let firebaseError = error {
            self.createAlert(title: "Error", message: firebaseError.localizedDescription)
            return
         }
                
  })
}
    • Real database
//Example of retrieve data from Firebase
let userID = (Auth.auth().currentUser?.uid)!
        Database.database().reference().child("users").child(userID).observeSingleEvent(of: .value) { (snapshot) in
            if let dictionary = snapshot.value as? [String: AnyObject] {
                self.highInput.text = dictionary["high"] as? String
                self.weightInput.text = dictionary["weight"] as? String
            }
        }
//Example of update data from Firebase
@IBAction func modifyTouched(_ sender: Any) {
        let userID = (Auth.auth().currentUser?.uid)!
        ref = Database.database().reference()
        ref.child("users").child(userID).updateChildValues(["weight": weightInput.text!, "high": highInput.text!])
        alertModify(title: "Information", message: "You have modify your data")
    }

 

We can see the structure of Firebase. On the first screen, we can see the real database and on the second, the authentification table.

 

 

 

  • Social media
let activityController = UIActivityViewController(activityItems: ["Hi! I just finished my session on JumpIn app. I did \(self.newJump!) jumps, I burnt \(self.newCalories!) calories and my average altitude is \(self.newAltitude!) during \(self.newDuration!) minutes. Try this app! ?"], applicationActivities: nil)
        present(activityController, animated: true, completion: nil)

We didn’t put all our code like game part because it is very long, but you can find our complete code in the next part.

 

Demonstration

You can find our complete code on Bitbuck (Bitbucket) or on Github (Github).

 

References :

We essentially use the book “iOS Programming: The Big Nerd Ranch Guide” (6th edition) wrote by Christian Keur and Aaron Hillegass.

But sometimes, we look at some tutorials for precise subjects like :

 

Conclusion

  • Do we reach our objectives ?

According to the introduction, we think that our objectives are fully respected. Indeed, we learnt a lot about iOS Programming. We were very independent and we teach ourselves by looking at tutorials. Facing problems enable us to remember our errors and learn quickly.

Moreover, our application works and implements all our beginning requirements and even more because we implement also accelerometer so we don’t have anything more to implement.

 

  • What do we think about our project ?

We are pretty proud of our project because for all of us, it was our first step with iOS programming and Swift language. We think that for our first application the result is really correct : we succeed to create an application which embedded sensors : internal and external and we succeed to build an entire simple game.

Even if there are some parts to improve, we think that the application is completed. Indeed, there are some details with little crashs and the code can be more optimized.

 

  • Advantages and disadvantages

The first advantage and non insignificant is that the application works correctly on all kinds of Apple devices. Moreover, the Bluetooth jump counter works very well and it is impossible to cheat by shaking the sensor in our hand for example. One of the major advantages is the innovation. In accordance with our commitments, the application merges game and sports and it is only one application to do this actually.

However, there are some disadvantages. It is our first application so, sometimes there is some code which not really optimized. Indeed, we find some alternative methods in order to solve our problem and sometimes, it is longer and not optimized. Moreover, after a lot of tries, our accelerometer is not very accurate (compare to the Bluetooth sensor) and sometimes it is possible to cheat by shaking the phone from bottom to top instead of jumping. Furthermore, the calories are calculated according to time and weight but not in function of jumps so, if the user play start and wait without jumping, it still calculate the calories.

Finally, we know that there are some little details bugs in one or two views and we haven’t  succeeded to solve it yet.

 

  • Users’ evaluation

After realizing the application, we decide to install it on our phone and ask our friends to test it.The first impression is very positive, they don’t really that we build an app on our own and from scratch. Moreover, there are very good returns about the design, the attractiveness and the simplicity of using it.

Then, they go more in deep and saw some problems.For examples, there are sometimes bugs with the game, when we played many times, there is not a home button on the table view controller when we want to display statistics…etc.

But finally, the opinions are rather positive and they receive well our idea.

 

  • Perspectives

Our perspectives is to upload it on the App Store but in that way, we have to correct all the different problems and be sure that the application is fully operational. Moreover, we think also that we can add some animations on our app in order to make it the more attractive as possible.

Furthermore, if the application work well and that the users love it, we think about creating some updates by implementing new features, for example track new activities, add a chat for users, propose different games, etc…

Leave a Reply