Tutorial: Quickstart

iOS Quickstart

Create an account

  1. Create an account on [[siteUrl]].
  2. Once you're logged, create a [[service]] application.

Setup your project

You can configure your project manually or with CocoaPods.

  • Manual Configuration
    • Download the [[service]] SDK.
    • Copy the framework in your project.
    • Add the framework dependency to project's target.
  • Cocoapods setup
    • Add Webcom to your project's Podfile.
      target 'MyProject' do
      pod 'Webcom'
      end

Start coding

Include [[service]] header in your app :

  #import <Webcom/Webcom.h>
  import Webcom

Create a reference to your [[service]] database :

  /// Webcom reference
  WCWebcom * webcomRef = [[WCWebcom alloc] initWithURL:@"https://io.datasync.orange.com/base/{your-webcom-app}"];
  /// Webcom reference
  let webcomRef = WCWebcom(URL: "https://io.datasync.orange.com/base/{your-webcom-app}")

Write data :

  /// Say Hello
  [webcomRef set:@"Hello World!"];
  /// Say Hello
  webcomRef.set("Hello World!")

Read data :

  /// Read
  [webcomRef onEventType:WCEventTypeValue withCallback:^(WCDataSnapshot * _Nullable snapshot, NSString * _Nullable prevKey)
  {
      NSString * value = (NSString *)snapshot.value;
      NSLog(@"%@", value);
  }];
  /// Read
  webcomRef.onEventType(.Value , withCallback:
  {
    (snapshot: WCDataSnapshot?, prevKey: String?) -> Void in
      if let message = snapshot?.value as? String
      {
        print(message)
      }
  }

More