Giter Site home page Giter Site logo

pebble-ios-sdk's Introduction

PebbleKit iOS GitHub release Cocoapod Carthage compatible

Welcome to Pebble's official iOS SDK!

Examples

All Pebble SDK examples are available on GitHub.

You can also run pod try PebbleKit to jump into a simple project right away.

Integrating PebbleKit Using CocoaPods

  • Install CocoaPods or make sure it is up to date
  • Add a Podfile to your project if you don't have one already (Hint: use pod init).
  • Add this line to the Podfile: pod 'PebbleKit'
  • Run pod install

Integrating PebbleKit Using Carthage

  • Install Carthage or make sure it is up to date
  • Add Cartfile to your project if you don't have one already.
  • Add this line to the Cartfile: github "pebble/pebble-ios-sdk"
  • Run carthage bootstrap
  • Drag PebbleKit.framework into your project

Integrating PebbleKit Manually

  • Copy PebbleKit.framework somewhere in your project folder.
  • On your application target “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop PebbleKit.framework.
  • Link CoreBluetooth.framework.
  • Add -ObjC linker flag to your project's build settings.

Additionally, since PebbleKit.framework is compiled for both the device and the simulator, when you upload your app to iTunes Connect, it might be rejected. To avoid this, you need to strip the simulator architectures from the binary before submitting. You can do this in many ways, but we will recommend using Carthage for simplicity:

  • Install Carthage or make sure it is up to date

  • On your application target “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script with the following contents:

    /usr/local/bin/carthage copy-frameworks

    and add the paths to the framework under “Input Files”, e.g.:

    $(SRCROOT)/path/to/PebbleKit.framework
    

Integrating with PebbleKit-Static

PebbleKit-Static provides compatibility with iOS 7. We recommend you using PebbleKit, but if you need to provide versions of your app for older iOS version, you can still use this.

You can use PebbleKit-Static either using Cocoapods or manually. Carthage only supports dynamic frameworks, so PebbleKit-Static is not available for Carthage.

Additionally, in every point of the documentation that uses #import <PebbleKit/PebbleKit.h> you should use instead #import <PebbleKit-Static/PebbleKit.h>.

Using CocoaPods

  • Install CocoaPods or make sure it is up to date.
  • Add a Podfile to your project if you don’t have one already (Hint: use pod init).
  • Add this line to the Podfile: pod 'PebbleKit-Static'
  • Run pod install

Manually

  • Copy PebbleKit-Static.framework somewhere in your project folder.
  • On your application target “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop PebbleKit-Static.framework.
  • Link CoreBluetooth.framework.
  • Add -ObjC linker flag to your project's build settings.

Configure Info.plist and capabilities

If you want your app to communicate with the Pebble while in the background, you will need to add background modes to your app target Info.plist:

  • Add the following entries to the UIBackgroundModes ("Required background modes") array:
  • bluetooth-peripheral ("App shares data using CoreBluetooth")
  • bluetooth-central ("App communicates using CoreBluetooth")

If you use background modes you also need to update your target's Capabilities in Xcode. Enable Background Modes and select:

  • Uses Bluetooth LE accessories
  • Acts as a Bluetooth LE accessory

If you are compiling in Xcode 8 or greater, you must additionally add the following key Info.plist (and it is recommended that you do so in older versions):

  • NSBluetoothPeripheralUsageDescription (“Privacy - Bluetooth Peripheral Usage Description”)

Xcode Documentation

You can browse the latest documentation online (and install an offline docset if you click on the icon on the top right).

Alternatively, manually install the docset from this folder:

  • An Xcode docset is included with documentation about all public APIs
  • Copy PebbleKit-ios.docset content into ~/Library/Developer/Shared/Documentation/DocSets
  • Restart Xcode. The documentation will now be available from Help > Documentation and API Reference

Submitting iOS apps with PebbleKit to Apple's App Store

In order for Pebble to work with iPhones, Pebble is part of the Made For iPhone program (a requirement for hardware accessories to interact with iOS apps). Unfortunately this also means that if you build an iOS app with PebbleKit, Pebble will need to whitelist your iOS app before you can upload it to the App Store. If you have completed a Pebble app and would like to learn more about making it available on the App Store, please visit the whitelisting guide

Change Log

4.0.0

  • Added: Support for Pebble 2.
  • Added: New superclass PBSemanticVersion. PBFirmwareVersion is now a subtype of PBSemanticVersion.
  • Added: New values SendTextSupported, NotificationsFilteringSupported, UnreadCoredumpSupport, and WeatherApp2 in PBRemoteProtocolCapabilitiesFlags.
  • Added: PBPebbleKitLogging type to customize the logging callback used by PebbleKit and the log level.
  • Changed: Remove outdated documentation for PBWatch. Improved documentation about -[PBWatch friendlyDescription].
  • Changed: Clean up the PBDataLoggingService header. Use modern type names and improve nullability annotations.
  • Changed: Added nullability annotations to NSDictionary+Pebble.h. Deprecated old methods without pb_ prefix and added alternative methods with pb_ prefixes instead.
  • Changed: Added nullability annotations to NSNumber+stdint.h. Deprecated old methods without pb_ prefix and added alternative methods with pb_.
  • Changed: Deprecated method for setting the default log level in PBPebbleCentral in favor of the new methods in PBPebbleKitLogging.
  • Changed: Communication with the watches (both through Classic and through LE) will not longer happen in the main thread. The callbacks will still be invoked in the main thread, and many methods are still documented as needed to be called from the main thread. We might lift those restrictions in the future, but they are still in place.
  • Changed: Clean up the Sports API and document and improve PBSportUpdate helper object.
  • Fixed: PebbleKit-Static uses the right header paths for Cocoapods.
  • Fixed: PebbleKit-Static is stripped of its debugs symbols, which should avoid printing some warnings.
  • Fixed: Golf and Sports do not need to add their UUID manually before using their APIs.
  • Fixed: Added correct nullability annotations for PBWatch (Golf) and PBWatch (Sports).
  • Fixed: Signature of appMessagesPushUpdate:withUUID:onSent: no longer declares a non-nullable NSError * named __nullableerror.
  • Fixed: Race condition that was making the communication with watch impossible.
  • Fixed: -[PBFirmwareVersion compare:] was reporting the wrong results for firmwares released far in the future.
  • Fixed: Connecting through Bluetooth LE should be more reliable.
  • Fixed: Don’t try connecting with devices that are not Pebble.
  • Fixed: Don’t try connecting with Pebble devices that are connected to other mobile devices.
  • Fixed: Added correct nullability annotation for PBVersionInfoCompletionBlock.
  • Fixed: Avoid crash while reconnecting to Bluetooth LE devices.
  • Deprecated: PBFirmwareVersion os, major, and minor, as well as the convenience initializer firmwareVersionWithOS:major:minor:suffix:commitHash:timestamp: has been deprecated. Use instead majorVersion, minorVersion, revisionVersion and firmwareVersionWithMajor:minor:revision:suffix:commitHash:timestamp:.
  • Removed: Support for Bluetooth Classic communication. Only Bluetooth LE is available. All devices in 3.x or later should be able to use Bluetooth LE, including the original Pebble and Pebble Steel. This should make communication from several third party apps a lot better.

3.1.1

  • Fixed: -[PBPebbleCentral lastConnectedWatch] is now properly marked as nullable.
  • Fixed: Avoid watches not connecting to the phone in some infrequent scenarios.
  • Fixed: When used from Objective-C++, -[PBWatch isNew] property doesn’t have the alias new to avoid problems with C++ reserved keywords.
  • Fixed: Added Bitcode to the dynamic frameworks, so apps that wants to use Bitcode can submit properly.

3.1.0

PebbleKit is now a dynamic framework.

If you want to support iOS 7.x add pod 'PebbleKit-Static' to your Podfile.

  • Added: Added workaround for Pebble 2.x / iOS 9 issue causing messages from watch not to arrive
  • Added: DataLogging now works better in multi-app setups.
  • Changed: DataLogging service is now created lazily when you try to use the API the first time
  • Changed: DataLogging won't unannounce server when you have Background Modes set
  • Changed: Lowered DeploymentTarget to 7.0 again
  • Fixed: DataLogging poll wouldn't be triggered on app launch
  • Fixed: appMessagesRemoveUpdateHandler not working as intended
  • Deprecated: dataLoggingService.pollForData - use pollForDataFromWatch: instead
  • Deprecated: central.dataLoggingService - use dataLoggingServiceForAppUUID: instead

3.0.0

  • Added: Support for Pebble Time Round
  • Added: Support for 8K app messages
  • Added: Support for Swift
  • Added: Support for Bitcode
  • Change: All appUUID properties are now NSUUID instead of NSData
  • Change: As soon as you set the delegate and the appUUID you must call run the central before you'll get any connection events: [[PBPebbleCentral defaultCentral] run]
  • Tip: Add bluetooth-peripheral and bluetooth-central to your UIBackgroundModes if your app should work while in the background
  • Tip: No need to check for lastConnectedWatch.isConnected at app launch anymore - just wait for the event after you invoked run
  • Tip: We removed PebbleVendor.framework. Keep it if you need it. Drop it otherwise to reduce the size of your app.

2.4

2.3

  • Removed: Bluetooth LE code from PebbleKit
  • Changes: Improvements to data logging to help troubleshoot issues
  • Removed: PBWatch+PhoneVersion and PBWatch+Polling
  • Fixed: PBWatch+Version report the correct version
  • Fixed: Crash when calling -[PBNumber description]
  • Changed: Imports now are using“HeaderName.h” format (instead of <PebbleKit/HeaderName.h>)
  • Fixed: Race-condition when sending data between phone and watch
  • Fixed: Made PebbleKit.podspec pass most-recent CocoaPod linter
  • Changed: Prefixed internally used logging classes to fix conflict when using CocoaLumberjack in your app
  • Changed: Made existing logging more descriptive

2.2

  • Removed: PBWatch+PhoneVersion
  • Fixed:PBWatch+Version reported the wrong version
  • Fixed: Crash when calling -[PBNumber description]

2.1

  • Changed: Improvements to data-logging to help troubleshoot issues

pebble-ios-sdk's People

Contributors

drodriguez avatar hbehrens avatar mrcljx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pebble-ios-sdk's Issues

App crashed in ExternalAccessory (iOS9)

Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000015d6d270

-[EAAccessoryManager _notifyObserversThatAccessoryDisconnectedWithUserInfo:]

And we can't update latest SDK since we need to support iOS7.
I know there is a static lib, but it doesn't work. Even can't build through CocoaPods.

appMessagesGetIsSupported frequently returns 0 when connection to Pebble classic from iOS SDK 3.0

Once watchDidConnect callback happens, call to appMessagesGetIsSupported appears to time out after 20 seconds and return 0.

See log:

2015-10-26 20:52:43.256 WristVision[652:20385] pebbleCentral:<PBPebbleCentral: 0x125e44810> watchDidConnect:<PBWatch: 0x125e452c0, Pebble C260, 33J0110FC260, iAP> isNew:0
2015-10-26 20:52:43.257 WristVision[652:20385] connectPebble
2015-10-26 20:53:03.273 WristVision[652:20385] appMessagesGetIsSupported callback, PBWatch = <PBWatch: 0x125e452c0, Pebble C260, 33J0110FC260, iAP>, isAppMessagesSupported = 0

new pebblekit (3.0.0) produces lots of warnings in xcode 7

about 80 instances of
warning: (x86_64) /var/folders/1y/tt8clntj75q79krs_0qwh8tw0000gp/T/tmpv8GzMH/Build/Intermediates/PebbleKit.build/Release-iphonesimulator/PebbleKit.build/Objects-normal/x86_64/PBWatch+LinkStatus.o unable to open object file: No such file or directory

& friends.

`watch.new` property is incompatible with Objective-C++

In PBWatch.h, there's a property called "new"; because that is a C++ keyword, this header file can't be included from Objective-C++ code.

As a workaround, I've surrounded that property declaration with "#ifndef __cplusplus", which works fine but needs to be re-added each time I update the framework.

Maybe rename the property?

Manual instructions in readme are incorrect

The instructions in 'Integrating PebbleKit Manually' don't work.

PebbleKit is a dynamic framework, but adding it to the project doesn't add it to embedded frameworks.

Also, -ObjC shouldn't be needed with dynamic frameworks.

There is no mention of including the PebbleKit-Static framework manually.

Allow removal of added AppUUIDs

We @ Lignite have an iOS app which needs to be able to communicate with 17+ UUIDs. Not all at once of course, just whenever a watchface/watchapp is on the screen. So, you’d probably think we could dynamically set the UUID, this is where the fun begins.

I have found that cannot add more than 10 UUIDs without your watch’s firmware crashing because the number of communication channels begins to make it unstable. So, why not just set 1 UUID and change it when another face opens?

Well, a face/app can’t tell the phone from itself that it’s awake because the channel needs to be open in the first place. I also can’t remove a UUID once it has been added. So if the user ends up using a lot of faces/apps in the time where the app is alive, then it will end up crashing the watch because of the “too many communication channels” issue.

We refuse to:
-Use JS
-Sideload apps
-Use the same UUID

All that needs to be done to PebbleKit is add the ability to set the UUID more dynamically or fix the amount of communication channels. I would even be happy with just being able to delete UUIDs 😄

Thanks for all of your work on PebbleKit, though!

Any chance of removing CocoaPods?

CocoaPods breaks the latest beta versions of XCode fairly frequently... I can just fork and remove it if you guys don't want to maintain a version without CocoaPods.

PebbleKit dynamic framework breaks with bitcode enabled

Embedding PebbleKit allows an archive with bitcode to be created, but doesn't allow exporting with app thinning.

During the export dialogue in Xcode, selecting the radio button for thinning produces an error.

When using xcodebuild on the command line, the error related to the thinning step always occurs, entirely breaking export. Using the default (none) and specifying in the export options do not prevent this.

The most likely culprit seems to be the log message: ""Failed to verify bitcode in PebbleKit.framework/PebbleKit:\nerror: Cannot extract bundle..."

See https://github.com/corvino/PebbleBitcode for a sample project replicating the issue and detailed description.

lastConnectedWatch in iOS 10.3

Are there any known issues with PebbleKit 4.0 on iOS 10.3? My iOS code was last confirmed working on iOS 10.2, but the PebbleCentral's lastConnectedWatch always returns nil now, and updating my iPhone to iOS 10.3 is the only thing I've changed. I have an original Pebble watch running the last-supported firmware version 3.12.3.

The registeredWatches and connectedWatches arrays are also empty. But the Pebble iOS app shows the watch as connected, and the watch settings page shows the phone as connected. Perhaps there was a new permission added in iOS 10.3 to allow watch access?

I wrote more info, including the code I'm using, on the Pebble developer forum: https://forums.pebble.com/t/no-app-connectivity-in-ios-10-3/29513

How to check if user has accepted Bluetooth permission?

In our on-boarding process there are completion handlers for permission requests so that we can make sure that the permission was granted before moving onto the next on-boarding step.

With PebbleKit however, calling the run function for the first time will launch the permission request though we have no way of knowing when the user finished choosing their option on the following popup which asks them for permission.

What is the most reliable way for us to check whether or not the user has accepted the permission?

Thanks!

appMessagesRemoveUpdateHandler() has no effect

self.msgHandle = pebbleDevice!.watch.appMessagesAddReceiveUpdateHandler()
{                                                                        
    (watch, message) in                                                  
    NSLog("hello")                                         
    return true                                                          
}                                                                        
pebbleDevice!.watch.appMessagesRemoveUpdateHandler(self.msgHandle!)  

This Swift code should not result in anything being logged, because we remove the handler right after adding it, right? But I do see "hello" printed when a message is received; in fact, if I call this snippet 3 times, I see "hello" printed 3 times for every message. So it seems that the handlers are not being removed.

Choose BluetoothLE over Bluetooth-Classic more reliably

Start app.
Connect to watch.

One of the following messages will appear in the console:

Not opening a session for <PBBTLEWatchTransport: 0x14e227fe0 identifier=LE-2FB28688-CE8C-4935-B668-479F4D29184F name=Pebble Time 5C53 serialNumber=Q303195E0074> - no free/matching App-UUID found.

  • or -

Not opening a session for <PBBTClassicWatchTransport: 0x13f25bd90 identifier=iAP-shared name=Pebble Time 5C53 serialNumber=Q303195E0074> - no free/matching App-UUID found.

There seems to be no rhyme or reason as to which is selected. Consecutive launches of the iOS app often have the opposite transport selected.

Update to support CocoaLumberjack 2.0

CocoaLumberjack 2.0 is out, and has deprecated the macros used in PBVendorLog.h. The macros in CocoaLumberjack.h are the ones to be used now.

Pebble's SDK should be updated to use the new macros.

isMobileAppInstalled always returning YES (iOS 9)

Added "pebble" to LSApplicationQueriesSchemes in the apps Info.plist. Calling the centrals isMobileAppInstalled when the watch connected.Result is always YES.

Tested with Xcode 7.0 & 7.1 and iPhone 5s iOS 9.0.2

Edit: nvm. misunderstood isMobileAppInstalled. pls close

CocoaPods create project only have dataLoggingService api

pod update --verbose --no-repo-update

it can't update to 3.1

Update all pods
Preparing

Analyzing dependencies

Inspecting targets to integrate
Using ARCHS setting to build architectures of target Pods-PebbleFindMe:
(``)

Finding Podfile changes

  • PebbleKit

Resolving dependencies of Podfile

Comparing resolved specification to the sandbox manifest

  • PebbleKit

Downloading dependencies

-> Using PebbleKit (3.0.0)

  • Running pre install hooks

Generating Pods project

  • Creating Pods project
  • Adding source files to Pods project
  • Adding frameworks to Pods project
  • Adding libraries to Pods project
  • Adding resources to Pods project
  • Linking headers
  • Installing targets
    • Installing target Pods-PebbleFindMe iOS 7.1
  • Running post install hooks
  • Writing Xcode project file to Pods/Pods.xcodeproj
    • Generating deterministic UUIDs
  • Writing Lockfile in Podfile.lock
  • Writing Manifest in Pods/Manifest.lock

Integrating client project

Integrating target Pods-PebbleFindMe (PebbleFindMe.xcodeproj project)

  • Running post install hooks
    • cocoapods-stats from
      /Library/Ruby/Gems/2.0.0/gems/cocoapods-stats-1.0.0/lib/cocoapods_plugin.rb

Sending stats
- PebbleKit, 3.0.0
Pod installation complete! There is 1 dependency from the Podfile and 1 total
pod installed.

com.apple.private.externalaccessory.showallaccessories

Hi!

There's a problem with entitlement on iOS 10.0+

2016-10-29 16:45:49.063492 PebbleKitExample[513:57904] Couldn't find the "com.apple.private.externalaccessory.showallaccessories" entitlement

I've added following entries to plist:

<key>UIBackgroundModes</key> <array> <string>external-accessory</string> <string>bluetooth-peripheral</string> <string>bluetooth-central</string> </array>

as well as

<key>NSBluetoothPeripheralUsageDescription</key> <string>BT</string>

and

<key>UISupportedExternalAccessoryProtocols</key> <array> <string>com.getpebble.public</string> </array>

There's no such problem on iOS < 10.0

appMessagesKill does not kill app when called during willTerminate

In my app WristVision, I have a UIApplicationWillTerminateNotification notification handler to terminated the watch app when the iPhone app exits. The hander eventually calls:

[self.targetWatch appMessagesKill:^(PBWatch *watch, NSError *error) {...}];

however, the watchapp never exits, and the callback is never called.

This code worked (and continues to work) fine with versions of the iOS SDK prior to 3.0.

appMessagesPushUpdate fails quietly on GCD side-thread

Handler is never invoked in this circumstance.

Expected behavior would be a not-main-thread exception.

//thread 1

    __weak HTPebbleDevice * weakSelf = self;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
    dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^(void){
        [weakSelf sendSomething];
    });

//Thread 47

-(void)sendSomething{
        NSDictionary *update = @{ @(1):[NSNumber numberWithUint8:1]};
        [self.connectedWatch appMessagesPushUpdate:update onSent:^(PBWatch *watch, NSDictionary *update, NSError *error) {
//this code isn't ever called ever
            if (!error) {
                NSLog(@"Successfully sent");
            }
            else {
                NSLog(@"Error sending : %@", error);
            }
        }];
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.