GithubHelp home page GithubHelp logo

nvdnkpr / node-ios Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tootallnate/node-ios

0.0 1.0 0.0 725 KB

Native node bindings to iOS functionality (vibrate, acceleromoter, geoservices, etc.)

Home Page: https://tootallnate.net/nodejs-on-ios

License: MIT License

node-ios's Introduction

node-iOS

Native node bindings to iOS functionality (vibrate, acceleromoter, geoservices, etc.)

This module offers native node binding to Apple iOS functionality, meant for node running on an Apple iDevice. It exposes low-level functionality of the device, like vibrate, sending SMS messages, displaying pop-up user notifications, simulating the home and lock buttons, and a lot more planned!

Considering the fact that most jailbroken devices won't have a GCC toolchain set up on their device, this repo includes a pre-built version of the module that hopefully will work on the majority of devices.

I'm always looking for ideas for additional APIs to add. So if you can think of any functionality that you want exposed to JavaScript that's missing from the API below, then please don't hesitate to open an Issue requesting it!

API

createNotification(options[, callback]) -> undefined

Creates and displays a pop-up "notification" onto the iDevice. The optional callback function will be called after the notification has been dismissed (through user interaction or otherwise cancelled).

The most recent call to this function will be the active notification. That is, if there's already an active notification, and this function is called, then the newly created notification will take precedence over any existing notifications. So if you want to display a series of notifications, it's better invoke the next one in the previous notification's callback.

iOS.createNotification({
  header: "Title",
  message: "Enter your name..."
}, function(err, response) {
  if (err) throw err;

  console.log(response);  
});

The options Object accepts the following parameters:

  • header - A String that will be used as the header of the notification. Defaults to null.
  • message - A String that will be used as the message body of the notification. Defaults to null.
  • defaultButton - The text of the default (primary) button. Defaults to 'OK'. To disable the default button (notification without any buttons), explicity pass null here.
  • alternateButton - The text of the secondary (alternate) button. Defaults to null (no second button).
  • otherButton - The text of the third (other) button. Defaults to null (no third button).
  • timeout - The timeout in seconds of the notification. Defaults to 0 for no timeout.

AddressBook

There's one global AddressBook instance that you may use to interact with the contents of your iDevice's central Address Book database. It's also possible to modify the Address Book by adding, editing or removing contacts or groups.

// The singleton AddressBook namespace:
iOS.AddressBook;

AddressBook.getContacts([filter,] callback)

Asynchronously retrieves an Array of "Contact" instances from the Address Book database that match the given filter. If no filter is given, then ALL contacts that are currently in the Address Book will be retrieved.

iOS.AddressBook.getContacts(function(err, contacts) {
  if (err) // Something went wrong

  console.log(contacts);
  // [ {
  //  firstName: 'John',
  //  lastName: 'Doe',
  //  numbers: { Mobile: '(555) 555-5555' } },
  //  ...
  // ]
});

vibrate() -> undefined

Vibrates the iDevice shortly. This is the same as when a text message or email arrives, etc. On devices that don't vibrate, this function does nothing (no error is thrown).

device() -> Object

Returns an Object containing properties from the current UIDevice. An example:

{ model: 'iPhone',
  localizedModel: 'iPhone',
  name: 'Nathan Rajlich’s iPhone',
  systemName: 'iPhone OS',
  systemVersion: '4.3.1',
  uniqueIdentifier: 'f1dfb3fa9f73fc9ffef4fcf3f61fff6f05ff1afb' }

sendSMS(number, message) -> Boolean

Sends an SMS with the specified message String to the specified number. Examples:

iOS.sendSMS('5555555555', 'this is a text message!');
iOS.sendSMS('555-555-5555', 'another text message!');
iOS.sendSMS('(555) 555-5555', 'and one more?!');
iOS.sendSMS(5555555555, 'you may just use a Number as well');

lockScreen() -> undefined

Locks the screen of the iDevice. Same effect as pressing the top "Lock" button.

quitTopApplication() -> undefined

Quits the currently visible application, going straight to the Home screen. On a device with multitasking support, the app will still be running in the process list. Same effect as pressing the "Home" button.

node-ios's People

Contributors

tootallnate avatar

Watchers

 avatar

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.