Teach you how to change the number of moves in the iOS version of QQwords 669 read 4770 reviews
Now a lot of software is added to the sports module, such as QQ and, and there are leaderboards, and friends who can compare the number of movement, anything as long as the addition of the comparison function, it becomes different. Today teach you to use code to modify the number of moves on QQ, modified the effect is this:
Screenshot 2016-06-21 pm 5.02.56.png This post is a learning mentality to look at this feature, if not like please skip. 1 Preparatory work
You need a device that an iOS programmer needs: a Mac system computer, a Xcode, a developer account (using the developer account), a license to use the HealthKit framework, and an Apple phone.
2 New Project
Since you have a developer account, I will only introduce important things, such as how to create a new project will not say.
1. Add the Healthkit.famework library.
2. Turn on the authorization and turn the HealthKit switch on.
786e95c6-e1e0-4272-bfbf-d19fbf4ce9ab.png
A file that is automatically downloaded when the switch is turned on is the suffix:. Entitlement files, such as file directories.
3 on the Code
1 Introducing Header Files
#import <HealthKit/HealthKit.h>
2 Initializing Hkhealthstore
hkhealthstore--Key Class (the class must be created using the HealthKit framework)
self.healthStore = [[HKHealthStore alloc] init];
3 Give a specific request permission, here we only need to write the number of steps to be able.
To create a type of step
NSSet *writeDataTypes = [NSSet setWithObjects:stepCountType, nil];
Make a specific request for permission
[self.healthStore requestAuthorizationToShareTypes:writeDataTypes readTypes:readDataTypes completion:^(BOOL success, NSError *error) { if (!success) { //失败了 return; } }];
The program runs to this back to the healthy cue screen, select the Allow option.
4 Set the number of steps and save
The data looks at the type of steps. Hkquantitytype *quantitytypeidentifier = [Hkobjecttype quantitytypeforidentifier:hkquantitytypeidentifierstepcount ];//represents the number of data units of the step hkquantity *quantity = [hkquantity quantitywithunit:[hkunit countUnit] Doublevalue:100]; //quantity sample. Hkquantitysample *temperaturesample = [hkquantitysample quantitysamplewithtype:quantitytypeidentifier Quantity: Quantity Startdate:[nsdate Date] enddate:[NSDate Date] Metadata:nil]; //Save [self.healthStore Saveobject:temperaturesample withcompletion:^ (bool success, nserror *error) {if (Success) {//saved successfully}else { Span class= "Hljs-comment" >//Save Failed}];
That 100 is the increase in the number of steps.
Then open the Health app on your phone and you'll find that the number of steps has increased. Again open QQ in the movement, the number of steps also increased. Theoretically, as long as the number of steps in the software is from the health application can be changed, not just QQ OH!!!!!
Demo:https://github.com/idage/idagechangeqqsport
Teach you how to change the number of moves in the iOS version of QQ