This sample App demonstrates Handoff API usage. Handoff can only work in a properly signed app, with a valid provisioning profile and entitlements.
- Clone this repo
- Execute
npm install
- Duplicate
config-template.json
and rename it toconfig.json
- Fill the
APP_BUNDLE_ID
andTeamID
keys in theconfig.json
file according to your Apple Developer Account - Fill the
SIGN_IDENTITY
key according to your signing identity inKeyChain Access
app, such asMac Developer: John Doe (BK2LD34S34)
- Add the development
.provisionprofile
file inscripts/assets/
with the namedevelopment.provisionprofile
- Use
npm start
to start debug mode. Note: Handoff API will not work. - Use
npm run pack
to generate a properly signed and provisioned App in which Handoff will work. - You can observe Handoff working by allowing two compatible Mac devices which are signed into the same iCloud ID and have Handoff enabled in Preferences > General.
- Switching between tabs will use the
invalidateCurrentActivity
API to stop the previous user activity and broadcast a new one, or stopping broadcasting altogether in theAny thing
tab which doesn't have an associated user activity. - On the
topics
tab, theupdate-activity-state
API is used to grab the latest data available from theFirst name
field before a second device tries to continue it. Ifevent.preventDefault()
is not called, the Handoff continues as is. If it is called however, Electron will wait a call toapp.updateCurrentActivity()
, providing the updated data to the activity to be continued. Ifapp.updateCurrentActivity()
isn't called in a timely manner (1 second or less, depending on the devices being used, software version and or network/bluetooth conditions), the Handoff will fail andcontinue-activity-error
will be called.