To run the example project, clone the repo, and run pod install
from the Example directory first.
- iOS 8.0+
- Xcode 8
Chips is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Cips'
if not want use all service , check service usage for installation each service
import Cips
#import <Cips/Cips.h>
Note that the Firebase/Core
and Firebase/Messaging
is required if using QNOCK SDK.
pod 'Cips/Qnock'
Register qnock on appdelegate first using clientid and clientsecret from cms QNOCK.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Qnock.initWithClientId(clientid, withClientSecret: clientsecret) { (token) in
}
return true
}
Use when notification received on device. This used on App Delegate
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
let data = Qnock.instance().notifReceived(userInfo)
}
This function use for subscribe or register new user id or new channel to qnock.
Userid on this function from userid member client not userid Qnock.
Qnock.instance().subscribe(FCMTOKEN, withChannel: channel, userID: userid) { (response) in
//complete register
}
This function to use unsubscribe or unregister channel from qnock. Use when user want to stop notification or user has logout.
Qnock.instance().unsubscribe(FCMTOKEN, withChannel: channel) { (response) in
//complete unsubscribe
}
Change environment QNOCK PRODUCTION mode or SANDBOX mode
Qnock.setEnvironment(ENVIRONMENT)
pod 'Cips/Squad'
pod 'Cips/SquadSocial' // use this pod if use social login with fb
Init Squad on appdelegate first using clientid and clientsecret from cms Squad.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Squad.initWithClientId(clientid, withClientSecret: clientsecreet withCompanyId: companyid)
return true
}
This function to login on squad
Squad.instance().login(withEmail: email, andPassword: password) { (respon) in
//respon on squad
//get token an refresh token
}
This function to register on squad
Squad.instance().registerFirst(withEmail: email, password: pass, firstName: firstname, lastName: lastname, companyid: companyid, redirecturi: reduri, verifyuri: veriuri) { (respon) in
//respon on squad
}
note redirect uri and verfyuri can use from squad or make self
This function to get user info profile
Squad.instance().userInfoGet(withToken: token) { (respon) in
//respon on squad
}
This function to edit profile squad
Squad.instance().profileEdit(withData: data) { (respon) in
}
This field data format to send on profile edit, but not all field to insert, its depend on client and cms
let data = [
"access_token":"token",
"user_id":"userid",
"phone_number":"number",
"first_name":"first",
"last_name":"last",
"birth_place":"place",
"address":"address",
"country":"countryid",
"city":"cityid",
"zip":"zipcode",
"gender":"genderid",
"birth_date":"date"
]
note : gender id = 2 : male , 1 : female
You can get country list and city list include id from this function
Squad.instance().getListCountry { (respon) in
//list country
}
Squad.instance().getListCity(withCountryId: countryid) { (respon) in
//list city
}
Date format for birthdate is YYYY-MM-dd
This function to update profile picture squad user
Squad.instance().uploadImage(imageData, userid: userid, accessToken: token) { (respon) in
//Respon Squad
}
This function to refresh token if token expired
Squad.instance().tokenRefresh(withToken: refresh_token) { (respon) in
//Respon Squad
//update accesstoken and refreshtoken
}
This function to logout user squad
Squad.instance().logoutAccessToken(access_token, refreshToken: refresh_token) { (respon) in
//Respon Squad
}
This function to get user info for edit profile, respon field different each client
Squad.instance().resourceWithParamsGet(withToken: access_token) { (respon) in
//Respon Squad
}
This function to get forgot password
Squad.instance().passwordForgot(withUserid: "", email:email, verifyUrl: verifyuri, redirectUrl: redirecturi) { (respon) in
//Respon Squad
}
note: you can leave userid empty string
This function to update password user squad
Squad.instance().passwordUpdate(withAccessToken: access_token, userid: userid, oldPassword: oldPass, newPassword: newPass) { (respon) in
//Respon Squad
}
This function to update email user squad
Squad.instance().emailUpdate(withAccessToken: access_token, userid: userid, newEmail: email, password: password) { (respon) in
//Respon Squad
}
This function to access squad using social
- Check Social
This function to check if social account has exist in squad
```swift
Squad.instance().socialCheckFromFacebook(withAccessToken: "token_fb", withUserId: "userid_fb") { (respon) in
}
```
```swift
Squad.instance().socialCheckFromTwitter(withUserId: "userid_twitter", withAccessToken: "token_twitter", withAcessTokenScret: "secret_twitter", withConsumerKey: "consumer_token_twitter", withConsumerSecret: "consumer_secret_twitter") { (respon) in
}
```
respon code from squad
200 = Success Login with social
202 = Failed login with Social but your email already registered on squad -> Use Login Social to continue login
203 = Failed login with social and cant access email on social ->Use login social or register social to continue
204 = Failed login with Social and your email not registered on squad -> Use register social to continue
- Login Social
This function to login with social first time, if return code from check social is 202 or 203
```swift
Squad.instance().socialLoginFromFacebook(withEmail: "Email_squad == email_fb", withPassword: "passwor_squad", withUserId: "userid_fb", withAccessToken: "token_fb") { (respon) in
}
```
```swift
Squad.instance().socialLoginFromTwitter(withEmail: "email_twitter == email_squad", withPassword: "pass_squad", withUserId: "userid_twitter", withAccessToken: "token_twitter", withAcessTokenSecret: "secret_twitter", withConsumerKey: "consumer_token_twitter", withConsumerSecret: "consumer_secret_twitter") { (respon) in
}
```
- Register Social
This function to register with social , if return code from check social is 203 or 204
```swift
Squad.instance().socialRegister(from: "facebook or twitter", withEmail: "email", withPassword: "pass", withUserId: "userid_social", withAccessToken: "token_social", withAcessTokenScret: "secret_twitter or 1 if fb", withConsumerKey: "consumer_token of 1 if fb", withConsumerSecret: "consumer_secret or 1 if fb", firstName: "first_name", lastName: "last_name", companyid: "company_id", redirecturi: "redirect_uri", verifyuri: "verify_uri") { (respon) in
}
```
Squad provide basic view controller you can use for login, register, update profile , etc. This list fuction to show view controll from squad
This to use login , register and forgot password from squad
SquadViewHelper.squadLoginView(with: view_controller, delegate: delegate)
Squad Controller Delegate
func squadLoginResponse(_ data: [AnyHashable : Any]!, status isSuccees: Bool, message: String!, controller: UIViewController!) {
}
Initialize this delegate if you usins social login with Twitter
func login(twitter complete: ((String?, String?, String?, String?, String?) -> Void)!) {
//login twitter sdk
complete("token_twitter","secret_twitter","consumer_token_twitter","consumer_secret_twitter","userid_twitter")
}
This to use view profile, edit profile and change profile picture squad
SquadViewHelper.squadProfileView(with: view_controller, token: token)
This function to init squad on first time app run
[Spotlight initWithAppsSecret:APPS_SECRET withClientId:APPS_ID withCompanyId:COMPANY_ID completion:^(bool isSuccess, NSString *responseToken) {
NSLog(@"LOGIN SPOTLIGHT %@",responseToken);
}];
This function get channel list
[Spotlight.instance spotlightChannelListWithUserId:@"guset" onComplete:^(SpotlightResponseModel *response) {
}];
List function to get list article homepage by type and channel
- Homepage Headline with Channel
[Spotlight.instance spotlightHomepageHeadlineWithChannel:_channel onComplete:^(SpotlightResponseModel *response) {
}];
- Homepage Story with Channel
[Spotlight.instance spotlightHomepageStoryWithChannel:_channel onComplete:^(SpotlightResponseModel *response) {
}];
- Homepage Editor with Channel
[Spotlight.instance spotlightHomepageEditorChoiceWithChannel:_channel onComplete:^(SpotlightResponseModel *response) {
}];
- Homepage Newsboost with Channel
[Spotlight.instance spotlightHomepageNewsboostWithChannel:_channel onComplete:^(SpotlightResponseModel *response) {
}];
- Homepage Commercial with Channel
[Spotlight.instance spotlightHomepageCommercialWithChannel:_channel onComplete:^(SpotlightResponseModel *response) {
}];
- Homepage Boxtype with Channel
[Spotlight.instance spotlightHomepageBoxTypeWithChannel:_channel onComplete:^(SpotlightResponseModel *response) {
}];
List function to get list article by type
- Basic List Article
[Spotlight.instance spotlightArticleWithWithUserId:@"guset" page:0 limit:10 onComplete:^(SpotlightResponseModel *response) {
}];
- Basic List Article with Channel
[Spotlight.instance spotlightArticleWithChannel:channelNo withUserId:@"guest" page:0 limit:10 onComplete:^(SpotlightResponseModel *response) {
}];
- Standard List Article
[Spotlight.instance spotlightArticleStandardWithUserId:@"guest" page:0 limit:10 onComplete:^(SpotlightResponseModel *response) {
}];
- Standard List Article with Channel
[Spotlight.instance spotlightArticleStandardWithChannel:channelNo withUserId:@"guest" page:0 limit:10 onComplete:^(SpotlightResponseModel *response) {
}];
- List Article Gallery
[Spotlight.instance spotlightArticleGalleryWithUserId:@"guest" withPage:0 limit:10 onComplete:^(SpotlightResponseModel *response) {
}];
- List Article Gallery with Channel
[Spotlight.instance spotlightArticleGalleryWithChannel:channelNo withUserId:@"guest" page:0 limit:10 onComplete:^(SpotlightResponseModel *response) {
}];
- List Article Group
[Spotlight.instance spotlightArticleGroupWithUserId:@"guest" withPage:0 limit:10 onComplete:^(SpotlightResponseModel *response) {
}];
- List Article Group with Channel
[Spotlight.instance spotlightArticleGroupWithChannel:channelNo withUserId:@"guest" page:0 limit:10 onComplete:^(SpotlightResponseModel *response) {
}];
- List Article Around me
[Spotlight.instance spotlightArticleAroundMeWithLatitude:@"latitude cordinate" longitude:@"longitude cordinate" radius:@"10" withUserId:@"guest" page:0 limit:10 onComplete:^(SpotlightResponseModel *response) {
}];
- Detail Article
This function to get Detail article
[Spotlight.instance spotlightArticleDetailWithId:_article_id withUserId:@"guest" onComplete:^(SpotlightResponseModel *response) {
}];
- Share Article
This function to share article
[Spotlight.instance spotlightArticleShareWithArticleNo:article_no withUserId:@"guset" type:@"2" fromEmail:@"abc@codigo.id" toEmail:@"test2@codigo.id" message:@"test" onComplete:^(SpotlightResponseModel *response) {
}];
- List Live Streaming with Channel
This function to get list live streaming
[Spotlight.instance spotlightLiveStreamingWithChannel:channelNo withUserId:@"guest" onComplete:^(SpotlightResponseModel *response) {
}];
- Share Live Streaming
This function to share live streaming
[Spotlight.instance spotlightLiveStreamingShareWithStreamingId:live_streaming_no userid:@"guest" shareType:@"2" fromEmail:@"test@mailhog.codigo.id" toEmail:@"test2@mailhog.codigo.id" message:@"msg" onComplete:^(SpotlightResponseModel *response) {
}];
- List Reaction on Article
This function to get list Reaction
[Spotlight.instance spotlightReactionListWithArticleId:article_no withUserId:@"guest" onComplete:^(SpotlightResponseModel *respon) {
}];
- Submit Reaction on Article
This function to submit Reaction
[Spotlight.instance spotlightReactionSubmitWithArticleId:article_no withReactionNo:@"2" withUserId:@"guest" onComplete:^(SpotlightResponseModel *response) {
}];
- List Story without channel
This function to get list story without channel
[Spotlight.instance spotlightStoryListWithUserid:@"guest" page:0 limit:10 limitArticle:@"10" onComplete:^(SpotlightResponseModel *response) {
}];
- List Story with Channel
This function to get list story with channel
[Spotlight.instance spotlightStoryListWithChannel:channel_no withUserId:@"guest" page:0 limit:10 limitArticle:@"10" onComplete:^(SpotlightResponseModel *response) {
}];
- Detail Story
This function to get story detail
[Spotlight.instance spotlightStoryDetailWithStoryNo:_story_no withUserId:@"guest" limitArticle:10 onComplete:^(SpotlightResponseModel *response) {
}];
iOS Codigo, ios@codigo.id
Chips is available under the MIT license. See the LICENSE file for more info.