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

react-native-web-help-desk

v1.0.0

Published

React Native package to integrate to web help desks like Zendesk and Freescout.

Downloads

3

Readme

About

This project came from the need to integrate the Zendesk help desk to an Expo app. There's no support to Expo or React Native from Zendesk dev team and the native APIs they made couldn't be used unless we ejected the project. Since we would like to keep the managed workflow, we thought of using the web API. It was of great help the gist found in https://gist.github.com/hetmann/bda29c335da8bb51f8e2e2d520edf3b6, it was this project's main inspiration.


Installing

You will need to install two peer dependencies in your project:

  • react-native-safe-area-context: ^3.3.2
  • react-native-webview: ^11.15.0

Yarn:

yarn add react-native-safe-area-context@^3.3.2 react-native-webview@^11.15.0

Npm:

npm install --save react-native-safe-area-context@^3.3.2 react-native-webview@^11.15.0

Then install this package.

Yarn:

yarn add react-native-web-help-desk

Npm:

npm install --save react-native-web-help-desk


Getting started

The first thing you will need is a html page containing the cdn script for your help desk. This can be either a real website, maybe an IP address like https://171.68.22.118/help-desk, or a html file accessible from the device filesystem.

HTML example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Chat</title>
    <script src="<url to load your help desk widget>"></script>

    <!-- This will allow using the native activity indicator in the background of the webview -->
    <style>
        body {
            background-color: transparent;
        }
    </style>

</head>
<body>
<script>
    <!-- If you need any extra code to be executed, you can try putting it here -->
</script>
</body>
</html>

Importing from the filesystem (expo)

The easiest way to get a uri from a local file using expo is using expo-asset. Let's say you created a chat.html file in the folder assets, the you can get its uri this way:

import React from 'react';
import {WebHelpDeskProvider} from 'react-native-web-help-desk';
import {Text, TouchableOpacity} from "react-native";

const WebHelpDeskInitializer: React.FC = ({children}) => {
    const webHelpDesk = useWebHelpDesk();
    const [assets] = useAssets(require('./assets/chat.html'));

    return (
        <SafeAreaView style={{flex: 1}}>
            {children}
            {webHelpDesk.ready &&
                <TouchableOpacity
                    onPress={() => webHelpDesk.open()}
                    style={{position: 'absolute', right: 20, bottom: 20, backgroundColor: 'blue'}}
                >
                    <Text>Open</Text>
                </TouchableOpacity>
            }
        </SafeAreaView>
    )
}

export default function App() {
    
    return (
        <WebHelpDeskProvider
            uri={assets ? assets[0].localUri! : ''}
            initScript="helpDesk.open();"
        >
            {children}
        </WebHelpDeskProvider>
    );
}

Reference

Don't panic, I also hate when there is a package that seems really nice, but there's almost none documentation about it, so this time you can relax and read all you need to know about this project in the wiki.


Contribute

This is a small project based on a gist. There's no "guide" for contributing and all help is welcome. Feel free to make a pull request, open as many issues as you need (I'll do my best to answer) and even contact me at [email protected].