1.2.26 • Published 2 months ago

owic-app-service v1.2.26

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
-
Last release
2 months ago

OWiC App Service

Introduction

OWiCAppService is a JavaScript package designed to enable web app developers to integrate their applications seamlessly with OWiC Connect. OWiC Connect is a platform used for scanning OWiC tags and providing enhanced interactive experiences. By using OWiCAppService, developers can turn their web apps into Experiences for OWiC Connect, facilitating a two-way communication system between the Experience (running in an iframe or webview) and the OWiC Connect application.

Installation

To install the OWiCAppService package, run the following command in your project directory:

npm install owic-app-service

Usage

To use OWiCAppService in your project: 1. Import OWiCConnect:

import OWiCConnect from 'owic-app-service';
  1. Initialize OWiCConnect in your application's main component. For example, in Vue.js:
    // In App.vue's mounted function
    mounted() {
      OWiCConnect.initialize();
    }

API Documentation

OWiCAppService provides the following methods for interacting with OWiC Connect:

initialize()

Initializes the two-way communication system between the Experience and OWiC Connect.

  • Usage: OWiCConnect.initialize()

getTagInfo()

Retrieves detailed information about the scanned OWiC tag.

  • Returns: A Promise resolving to an object containing tag details. Example response:
    {
      "id": "tag-unique-id",
      "created_time": "creation-timestamp",
      "last_edited_time": "last-edit-timestamp",
      "created_by": { "id": "creator-user-id" },
      "last_edited_by": { "id": "editor-user-id" },
      "permissions": {
        "public": { "read": true, "write": true },
        "anon": { "read": true, "write": false }
      },
      "app": {
        "appId": "associated-app-id",
        "appData": { /* Custom app data */ }
      },
      "platform": "web | mobile",
      "tag_id": "tag-identifier"
    }

getPlatform()

Determines the platform on which the Experience is running.

  • Returns: A string indicating the platform ('web' or 'mobile').

getData(key)

Fetches data associated with a specified key.

  • Parameters:
    • key (String): The key of the data to retrieve.
  • Returns: A Promise resolving to the requested data. Example response for key = "videoGift":
    {
      "video": {
        "filename": "video-file-name",
        "url": "video-url",
        "type": "video-type"
      },
      "montage": [
        {
          "type": "image-type",
          "displayMode": "display-mode",
          "url": "image-url",
          "filename": "image-file-name"
        }
      ]
    }

getUser()

Retrieves information about the current user.

  • Returns: A Promise resolving to an object with user details. Example response:
    {
      "id": "response-id",
      "data": {
        "user-id": {
          "uid": "user-id",
          "email": "user-email",
          "displayName": "user-display-name",
          "photoURL": "user-photo-url"
        }
      },
      "errors": []
    }

uploadMedia(fileObj, update)

Uploads media and provides progress updates.

  • Parameters:
    • fileObj (Array): An array of file objects.
    • update (Function): A function called with upload progress.
  • Returns: A Promise resolving to an array of uploaded file details. Example response:
    [
      {
        "type": "file-type",
        "filename": "file-name",
        "url": "file-url"
      }
    ]

setData(key, data)

Stores data under a specified key.

  • Parameters:
    • key (String): The key under which to store the data.
    • data (Any): The data to store.
  • Returns: A Promise resolving to an acknowledgment object. Example response for key = "memories":
    {
      "id": "response-id",
      "data": {
        "memories": [
          {
            "url": "image-url",
            "type": "image-type",
            "filename": "image-file-name"
          }
        ]
      },
      "errors": []
    }

Examples

Here are some examples of how to use OWiCAppService:

Initializing Communication

// In a React component
componentDidMount() {
  OWiCConnect.initialize();
}

Fetching Tag Data

async function getTagData() {
  let tagData = await OWiCConnect.getTagInfo();
  console.log(tagData);
}

Contribution

Contributions to OWiCAppService are welcome! Please read our contribution guidelines for more information.

License

OWiCAppService is licensed under AGPLv3 License.

1.2.26

2 months ago

1.0.0

5 months ago