Pebbleton 1.0.3

Pebbleton 1.0.3

许可证 MIT
发布最新发布2015年7月

Rudy Gomez 维护。



Pebbleton 1.0.3

  • 作者:
  • Rudy Gomez

iOS Pebbleton SDK v1.0.3

轻松愉悦地使用 Pebble。

特性

  • 无需代理的 Singleton 便利方法
  • 通过缓冲区发送消息以避免冲突
  • 将较大的字典分割成单个消息
  • 预配置可切换回调日志
  • 发送任意大小的字典(即将推出!)

通过 CocoaPod 安装

步骤 1:将 pods 添加到 Podfile

pod 'Pebbleton’, '~> 1.0’

步骤 3:不要忘记您的密钥

以下密钥应添加到目标的 .plist 中

'Requires Background Mode' => 'App communicates with external device'
'Supported external accessory protocols' => 'com.getpebble.public'

如何使用

1. 包含框架

#include <Pebbleton/Pebbleton.h>

2. 初始化 Singleton

Pebbleton *sharedPebbleton = [Pebbleton sharedInstance];
[sharedPebbleton initializeWithAppUUID:@"87c5be2a-b1dc-41bf-bc4f-b653c54ee7ae" andShowLogs:YES];

3. 调用方法和回调

[sharedPebbleton printInfo];

// pass nil as callback if not needed
[sharedPebbleton printFirmwareInfoWithCallback:nil];

[sharedPebbleton launchAppWithCallback:^(PBWatch *watch, NSError *error){
    NSLog(@"My launch app callback");
}];

[sharedPebbleton checkCompatibilityWithCallback:^(PBWatch *watch, BOOL isAppMessagesSupported){
    NSLog(@"My compatibility callback");
}];

[sharedPebbleton setPebbleCentralWatchDidConnectCallback:^(PBPebbleCentral *central, PBWatch *watch, BOOL isNew){
    NSLog(@"My conncection callback");
}];

4. 从手表接收消息

[sharedPebbleton setAppMessageReceiveUpdateHandler:^(PBWatch *watch, NSDictionary *update){
    NSLog(@"My received message callback");
}];

5. 向手表发送消息

// dictionary must be small enough to keep payload under 124 bytes
[[Pebbleton sharedInstance] sendMessage:@{@(KEY_TITLE_DATA): @"Title",
                                          @(KEY_DESC_DATA_1): @"Description"}
                           withCallback:nil];

// each key/value set must be small enough to keep payload under 124 bytes
NSDictionary *messages = @{@(KEY_TITLE_DATA): @"Long Title",
                           @(KEY_DESC_DATA_1): @"Long Description.",
                           @(KEY_DESC_DATA_2): @"Long Description gets cut-off",
                           @(KEY_START_DATA): @"Jan 03, 2015 2:00pm",
                           @(KEY_END_DATA): @"Jan 06, 2015 2:00pm"};

void (^callbackBlock)(PBWatch *watch, NSArray *errors) = ^(PBWatch *watch, NSArray *errors){
    if (errors.count) {
        NSLog(@"Errors sending my dictionary: %@", errors);
    } else {
        NSLog(@"Successfully my sent dictionary.");
    }
};

[[Pebbleton sharedInstance] sendDictionary:messages withCallback:callbackBlock];

重写 PBPebbleCentralDelegate(可选)

- (void)pebbleCentral:(PBPebbleCentral*)central 
      watchDidConnect:(PBWatch*)watch 
                isNew:(BOOL)isNew {
    // YOUR CODE HERE

    [Pebbleton sharedInstance].watch = watch;
}

- (void)pebbleCentral:(PBPebbleCentral*)central 
   watchDidDisconnect:(PBWatch*)watch {
    // YOUR CODE HERE

    if ([Pebbleton sharedInstance].watch == watch || 
            [watch isEqual:[Pebbleton sharedInstance].watch]) {
        [Pebbleton sharedInstance].watch = nil;
    }
}

变更日志

v1.0.1-1.0.3

  • 同步新的 README 到 CocoaPods 的新标签
  • 新版本号的新标签
  • 小的日志更改

v1.0.0

  • 官方发布

v0.1.4

  • 现在使用官方 CocoaPod 发布

v0.1.3

  • 添加 PebbleKit 依赖到 CocoaPod
  • 添加自定义框架和调试日志

v0.1.2

  • 创建 API 和私有头文件和目录
  • 添加公共 HeaderDoc 注释以生成文档
  • 添加缺少的回调参数
  • 重构初始化方法

v0.1.1

  • 公共方法用于通过发送每个键/值对来发送字典
  • 重构了初始化和设置器公开方法
  • 更改了一些类的属性的可见性