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

@kirz/react-native-apphud

v1.4.1

Published

Apphud SDK for react native

Downloads

6

Readme

react-native-apphud-sdk

Apphud SDK for react native

Installation

npm install @apphud/react-native-apphud-sdk

Usage

import ApphudSdk from "@apphud/react-native-apphud-sdk";

// ...

Initialize SDK

To initialize Apphud SDK you will need SDK Token. It is a unique identifier of your Apphud application. You can get it in your Apphud application settings under General tab

Basic initialization looks like this:

await ApphudSdk.start({ apiKey: "your_api_key" });

Initialization Options

|property|type|platform|required |---|---|---|---| |apiKey|String|iOS, Android|yes |userId|String|iOS, Android|no |deviceId|String|Android|no |observerMode|Bool|iOS|no

You can also initialize SDK with custom Device ID. This should be used if you plan to use logout / login features. You can pass the same identifier to Device ID and User ID:

await ApphudSdk.startManually({ apiKey: "your_api_key", deviceId: "", userId: "" });

Log out method will clear all saved data and reset SDK to uninitialised state:

await ApphudSdk.logout();

Purchase using Apphud Billing Client

To make a purchase call:

await ApphudSdk.purchase(productIdentifier);

Check Subscription Status

await ApphudSdk.hasActiveSubscription();

Returns true if user has active subscription. Use this method to determine whether to unlock premium functionality to the user.

Get Products

Apphud automatically fetches SKProduct/SKDetails objects upon launch. Make sure products identifiers are added in Apphud products. To get your products call:

await ApphudSdk.products();

Get Subscription Details

To get subscription object (which contains expiration date, autorenewal status, etc.) use the following method:

await ApphudSdk.subscription();

Check Non-renewing Purchase Status

Use this method to check whether the user has purchased in-app purchase and it's not refunded. Returns false if was never purchased or is refunded.

await ApphudSdk.isNonRenewingPurchaseActive(productIdentifier)

Get Non-renewing Purchase Details

To get non-renewing purchases, which contain purchase date, product identifier and cancellation date, use the following method:

await ApphudSdk.nonRenewingPurchases();

Get User ID

To get user id you can use this method:

await ApphudSdk.userId()();

Integrations

Submit attribution data to Apphud from your attribution network provider.

await ApphudSdk.addAttribution(options);

Restore Purchases (only iOS)

If your app doesn't have a login system, which identifies a premium user by his credentials, then you need a "restore" mechanism.

await ApphudSdk.restorePurchases();

Basically it just sends App Store Receipt to Apphud and returns subscriptions (or nil, if subscriptions are never purchased), non-renewing purchases (or nil, if there are no any) and an optional error.

Observer Mode (Android)

If you use your own billing then you should sync purchases each time user makes any purchase or restoration. Just call after purchase or restore:

await ApphudSdk.syncPurchases();

Keep in mind, that you are responsible for acknowledging or consuming all purchases in observer mode!

Migrate existing purchases (Android)

If you need to migrate existing purchases in case you already have a live app or if you need to restore purchases when user hits Restore button, just call syncPurchases() method.

await ApphudSdk.syncPurchases();

Do not migrate purchases on every app launch. One successful time is enough. Store flag in your app if purchases were successfully migrated

Troubleshooting

Build failed (xCode >= 12.0)

The error log

Undefined symbol: __swift_FORCE_LOAD_$_swiftWebKit

You should add libswiftWebKit.tbd to Link Binary with Libraries (from project, Build Phases)

alt text

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT