首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >pebbleCentral:watchDidConnect从不在iOS上被调用

pebbleCentral:watchDidConnect从不在iOS上被调用
EN

Stack Overflow用户
提问于 2016-01-27 17:13:20
回答 1查看 68关注 0票数 1

我有一个旧的Pebble Classic手表,升级到最新的固件(3.8.2),并使用最新的Pebble-SDK。

我已经按照下面几个简单的步骤安装了SDK,设置了一个Xcode项目,并添加了初始化和连接的代码:https://developer.getpebble.com/guides/mobile-apps/ios/

我的问题是,委托方法pebbleCentral:watchDidConnect从不被调用!

我正在使用iPad上的Pebble Time应用程序在手表中安装watchApp,所以我知道iPad已经连接到手表上了。运行iOS应用程序的是同一个iPad,该应用程序显然不会发现手表。

我试着从一位同事那里导入一个旧的测试项目,他在一两年前运行了它。同样的手表,同样的watchApp,当然还有更老的固件和软件开发工具包版本。同样的结果。

我认为pebble网站上的文档非常简单易懂。然而,我觉得我遗漏了一些关于这个watchDidConnect应该如何以及何时触发的解释。

我很可能在某个地方遗漏了一些简单的步骤,但我完全迷失在哪里去寻找!

欢迎任何想法!

编辑:我的代码看起来像这样:

ViewController.h:

代码语言:javascript
复制
#import <UIKit/UIKit.h>
@import PebbleKit;

@interface ViewController : UIViewController<PBPebbleCentralDelegate>

@end

ViewController.m:

代码语言:javascript
复制
#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) PBWatch* connectedWatch;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [PBPebbleCentral defaultCentral].delegate = self;

    [[PBPebbleCentral defaultCentral] run];

    NSLog(@"Pebble initialised");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)pebbleCentral:(PBPebbleCentral*)central watchDidConnect (PBWatch*)watch isNew:(BOOL)isNew {
    NSLog(@"Pebble connected: %@", [watch name]);
    self.connectedWatch = watch;
}

- (void)pebbleCentral:(PBPebbleCentral*)central watchDidDisconnect:(PBWatch*)watch {
    NSLog(@"Pebble disconnected: %@", [watch name]);

    if ([watch isEqual:self.connectedWatch]) {
        self.connectedWatch = nil;
    }
}

@end
EN

回答 1

Stack Overflow用户

发布于 2016-01-27 17:26:34

在设置好Pebble central之后,您是否正在调用-run方法?我注意到您发布的链接中的代码片段没有显示设置中心的delegate

[PBPebbleCentral defaultCentral].delegate = self; // Set your delegate

[PBPebbleCentral defaultCentral].appUUID = [[NSUUID alloc] initWithUUIDString:@"Your Pebble App UUID"]; // Set the app UUID

[[PBPebbleCentral defaultCentral] run]; // Call -run on the central

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35033072

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档