npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nativescript-watchos-connector

v2.0.0

Published

This is a NativeScript plugin that uses Apple WatchConnectivity to pass and receive data to a companion WatchOS app.

Downloads

11

Readme

nativescript-watchos-connector

This is a NativeScript plugin that uses Apple WatchConnectivity to pass and receive data to a companion WatchOS app.

Prerequisites / Requirements

Before using this plugin, make sure you have followed the NativeScript blog post on Developing a watchOS Extension For Your NativeScript App and iOS WatchOS Applications.

Installation NativeScript 7

npm i nativescript-watchos-connector

Installation prior to NativeScript 7:

npm i [email protected]

Usage

NativeScript Angular

  1. For this plugin to work you must first add the nativescript-watchos-connector as a provider in your app.module.ts:

TypeScript

import  {  WatchOSConnector  }  from  'nativescript-watchos-connector'

@NgModule({
	bootstrap: [AppComponent],
	imports: [],
	providers: [ WatchOSConnector ],
	declarations: [ AppComponent ],
	schemas: [ NO_ERRORS_SCHEMA ]
})
  1. Import the nativescript-watchos-connector plugin:

TypeScript

import  {  WatchOSConnector  }  from  'nativescript-watchos-connector'
  1. Create an instance of the import in the constructor:

TypeScript

constructor(
	private _watchOSConnector: WatchOSConnector
) {}

Plugin Overview

This is a list of all currently available functions and a brief description of their usage within this plugin.

|Function | Description | |--|--| |createWCSession() |Creates a WCSession| |watchOSChecker()|Checks if the user is on iOS, has an Apple Watch paired and the WatchOS app is installed| |checkActivation()|Checks if the WCSession is active (if not, session will be activated)| |convertInt(value)|Return value as Obj-C int| |convertDouble(value)|Return value as Obj-C double| |convertFloat(value)|Return value as Obj-C float| |sendObjectToWatch('objectKey', object)|Send the data to the companion WatchOS App using ApplicationContext|

createWCSession()

createWCSession checks if the device can support a WCSession, if so a WCSession will be created.

TypeScript

this.watchOSConnector.createWCSession()

watchOSChecker()

Use watchOSChecker instead of isIOS when working with passing data to the Apple Watch. This checks if the user is on iOS, has an Apple Watch paired and the WatchOS app is installed (returns boolean)

TypeScript

if (this.watchOSConnector.watchOSChecker()) {
// Only run if WatchOS app is avalaible
}

checkActivation()

Checks if the WCSession is active, if not this will activate the current session. This is called in sendObject() to ensure there is an active session.

TypeScript

this.watchOSConnector.checkActivation()

convertInt(value)

Returns the value as a NSNumber with int

TypeScript

this.watchOSConnector.convertInt(2319)

convertDouble(value)

Returns the value as a NSNumber with double

TypeScript

this.watchOSConnector.convertDouble(42.957194)

convertFloat(value)

Returns the value as a NSNumber with float

TypeScript

this.watchOSConnector.convertFloat(882.152)

sendObjectToWatch(objectKey, object)

Sends the data to the companion WatchOS app using updateApplicationContext. You need to pass in a key for the object and an object of Objective-C valid values.

TypeScript

let intValue =  this.watchOSConnector.convertInt(4)
let doubleValue =  this.watchOSConnector.convertDouble(45.1)

let numberObject =  {
	convertedInt: intValue,
	convertedDouble: doubleValue
}

this.watchOSConnector.sendObject('numberObjectKey', numberObject)

v2.0.0 Release

  1. Updated to be compatible with NativeScript 7

Future Releases

  • [ ] Add images to README
  • [ ] Create a demo app

Contributors

License

Apache License Version 2.0, January 2004