Latest 0.1.9
Homepage https://github.com/zenin-tech/J1ST-SDK-iOS
License MIT
Platforms ios 7.0
Frameworks UIKit, Foundation, MapKit
Authors

J1ST.IO iOS SDK

License MIT
CocoaPods
CocoaPods
Support

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

SDK 快速入门

注册开发者账号

[待补充]

新建产品

[待补充]

使用 CocoaPods 集成 iOS SDK

  • 安装 CocoaPods

    CocoaPods 是iOS下的第三方依赖管理工具,安装方式异常简单,Mac下都自带ruby,使用ruby的gem命令即可下载安装:

    $ sudo gem install cocoapods
    $ pod setup

  • 配置 Cocopods Podfile 文件,导入 J1ST.IO SDK

    新建一个名为 Podfile 的文件,以如下格式,将依赖的库名字依次列在文件中即可:

    platform :ios
    pod ‘J1STSDK’

  • 执行 Instal,完成 SDK 导入

    将编辑好的 Podfile 文件放到你的项目根目录中,执行如下命令即可:

    $ cd "your project home"
    $ pod install

    注:CocoaPods的详细安装和使用,参考 CocoaPods安装和使用教程

  • 项目设置 (iOS 9)

    由于iOS 9改用更安全的https,为了能够在iOS 9以上版本中正常使用 J1STSDK,请在 "Info.plist" 中进行如下配置,否则影响SDK的使用:

    <key>NSAppTransportSecurity</key>
    <dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
    </dict>

添加使用代码

  • 添加头文件

    #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];
    // 添加消息处理代码
    ……
    };

Latest podspec

{
    "name": "J1STSDK",
    "version": "0.1.9",
    "summary": "J1ST.IO SDK for iOS",
    "description": "J1ST.IO SDK for iOS by Zenin .",
    "homepage": "https://github.com/zenin-tech/J1ST-SDK-iOS",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Jarry": "[email protected]"
    },
    "source": {
        "git": "https://github.com/zenin-tech/J1ST-SDK-iOS.git",
        "tag": "0.1.9"
    },
    "platforms": {
        "ios": "7.0"
    },
    "frameworks": [
        "UIKit",
        "Foundation",
        "MapKit"
    ],
    "vendored_frameworks": "Frameworks/J1STSDK.framework"
}

Pin It on Pinterest

Share This