J1STSDK 0.1.9

J1STSDK 0.1.9

License MIT
ReleasedLast Release Oct 2016

Maintained by Jarry.



J1STSDK 0.1.9

  • By
  • Jarry

J1ST.IO iOS SDK

J1ST.IO 及时云平台应用,针对iOS设备,帮助开发者搭建奇思妙想的 IoT 产品。

SDK 快速入门

注册开发者账号

[待补充]

新建产品

[待补充]

添加使用代码

  • 添加头文件

    #import <J1STSDK/J1STSDK.h>
    
  • 初始化SDK

    从 Dev Console 获取当前 Product 的 Key ;

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 中添加初始化代码,使用 Dev Console 获取到的 Key 替换代码中的 Key :

    [J1STSDK startServiceWithProductKey:key 
                              resultBlock:^(NSString *result, NSError   *error) {
        if (result) {
            NSLog(@"Start success with Agent ID : %@", result);
        }
        else {
            NSLog(@"Start failed with error : %@", error.description);
        }
    }];
    
  • 上发数据

    定义上行数据内容(J1STUpstreamData),调用上发数据API接口:

    J1STUpstreamData *data = [J1STUpstreamData new];
    data.deviceType = AGENT;
    data.data = [NSDictionary dictionaryWithObjectsAndKeys:@"ZE16A", @"Model", 
                                                           @"1.0.0", @"FwVer", nil];
    [J1STSDK sendUpstreamData:data 
                   resultBlock:^(BOOL success, NSError *error) {
        if (success) {
              NSLog(@"Send Upstream Data Success");
      }
      else {
              NSLog(@"Send Upstream Data failed with error : %@", error.description);
      }
    }];
    
  • 接收数据

    在默认消息中心添加的监听代码 :

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                       selector:@selector(onMessageReceived:)   
                         name:kJ1STDidReceivedMessageNotification 
                                          object:nil];
    

    添加消息处理代码 :

    - (void)onMessageReceived:(NSNotification *)notification {
      J1STUpstreamData *data = [notification object];
      // 添加消息处理代码
      ……
    };