Git Product home page Git Product logo

ios-apps-chatsecure-chatsecure-push-ios's Introduction

ChatSecure-Push-iOS

The iOS SDK for ChatSecure-Push-Server.

Getting Started

Install

pod 'ChatSecure-Push-iOS', :git => 'https://github.com/ChatSecure/ChatSecure-Push-iOS'

Usage

1. Setup

If it's the first launch and there is no account.

let client = Client(baseUrl: NSURL(string: urlString)!, urlSessionConfiguration: NSURLSessionConfiguration.defaultSessionConfiguration(), account: nil)

Or if you already have an account. You'll need to store the username and token to make API requests.

let client = Client(baseUrl: NSURL(string: urlString)!, urlSessionConfiguration: NSURLSessionConfiguration.defaultSessionConfiguration(), account: account)

2. Create account

client.registerNewUser(username, password: password, email: nil, completion: { (account, error) -> Void in
  //Save account here
  })

3. Register new device

In order to register a new device first get an APNS token.

var settings = UIUserNotificationSettings(forTypes: (UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert), categories: nil)
application.registerUserNotificationSettings(settings)

Once you've recieved the token in the AppDelegate.

self.client.registerDevice(apnsToken, name: "New device name", deviceID: nil, completion: { (device, error) -> Void in
  //Save device here
  })

4. Get whitelist token to hand out to a friend

self.client.createToken(apnsToken, name: "New token", completion: { (token, error) -> Void in
  //Save and send to friend
})

5. Send a push message to a friend

Once you receive a token from a friend you can send them a push message.

data needs to be a dictionary that is serializable to JSON.

var message = Message(token: token, data: nil)
self.client.sendMessage(message, completion: { (msg, error) -> Void in
  println("Message: \(msg)")
  })

ios-apps-chatsecure-chatsecure-push-ios's People

Contributors

davidchiles avatar chrisballinger avatar

Watchers

James Cloos avatar PKCodeBox avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.