This provides a simple example of how to use ably-js
from within a React Native app.
It was written for manually testing the Webpack version 5 migration in ably/ably-js#1184, but I think serves as a generally useful example.
- Copy
.env.example
to.env
, and replaceinsert_key_here
with your Ably API key. - Run
npm install
. - Run
npm start
, and choose the one of the options to run on either iOS or Android. This will launch an iOS simulator or Android emulator.
You should see the following log messages in your terminal (the last two may appear in the opposite order):
Hello World, from React Native!
Attached to channel
Published to Ably
Got message from Ably
These steps use npm pack
, which emits a .tgz
file similar to that uploaded by npm publish
.
- Check out the
ably-js
repository at the commit you wish to test. - At the root of the
ably-js
repository, runnpm run build && npm pack --pack-destination <path>
, where<path>
is the directory you wish to output the.tgz
file to. - In the current repository, change the
package.json
’sdependencies.ably
entry to"file:<tgz-file-path>"
, where<tgz-file-path>
is the path to the.tgz
file output by the previous step. - Run
npm install
.