Skip to content

Ming-Tang/mojio-ios-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 

Repository files navigation

mojio-ios-sdk

Initializing the SDK

self.client = [MojioClient client];
[self.client initWithAppId:[APP_ID] andSecretKey:[SECRET_KEY] andRedirectUrlScheme:[REDIRECT_SCHEME] andIsSandbox:[YES for sandbox mode, NO for live]];

Authenticating a user

Logging In

[self.client loginWithCompletionBlock:^{
        // this is executed once the user is logged in
    }];

In addition, the application needs to be able to receive the authentication token when the Mojio server redirects it to the app. To do this, add the following lines of code to the app's ApplicationDelegate.m file:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    [self.client handleOpenURL:url];
    return YES;
}

Logging out

[self.client logoutWithCompletionBlock:^{
  // code is executed as soon as the user logs out
}];

Fetching Data

NSDictionary *queryOptions = @{@"limit" : @1, @"offset" : @0, @"sortBy" : @"LastContactTime", @"desc" : @"true"};
  [self.client getEntityWithPath:@"Vehicles" withQueryOptions:queryOptions success:^(id responseObject) {
    // executed when the data is successfully fetched
  }failure: ^{
    // executed if there was an error in trying to retrieve data
  }];

Getting a specific entity

[self.client getEntityWithPath:@"Vehicles/[VEHICLE_ID]" withQueryOptions:queryOptions success:^(id responseObject) {
  // executed when the data is successfully fetched
}failure: ^{
  // executed if there was an error in trying to retrieve data
}];

Saving an existing entity

[self.client updateEntityWithPath:@"Vehicles/{id}/Store/{key}" withContentBody: [CONTENT] success:^{
  // executed if the response is 200 or 201
} failure: ^{
  // executed if the request failed
}

Deleting an existing entity

[self.client deleteEntityWithPath:@"Vehicles/{id}/Store/{key}" success:^{
  // executed if the entity is deleted
} failure:^{
  // executed if the request failed
}

About

An ios client to the Mojio API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 90.5%
  • HTML 6.4%
  • CSS 1.2%
  • Other 1.9%