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

nativescript-fortumo-sms

v1.1.4

Published

A NativeScript module providing access to Fortumo SMS Gateway.

Downloads

12

Readme

npm npm

NativeScript fortumo SMS

A NativeScript module providing access to Fortumo SMS Gateway.

Donate

License

MIT license

Platforms

  • Android

Installation

Run

tns plugin add nativescript-fortumo-sms

inside your app project to install the module.

Android

AndroidManifest.xml

Keep sure to define the following permissions, activities and other data in your manifest file:

<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <!-- Open Stores -->
    <uses-permission android:name="org.onepf.openiab.permission.BILLING" />
    <!-- Google -->
    <uses-permission android:name="com.android.vending.BILLING" />
    <!-- Nokia -->
    <uses-permission android:name="com.nokia.payment.BILLING" />
    <!-- Samsung -->
    <uses-permission android:name="com.sec.android.iap.permission.BILLING" />
    <!-- Fortumo -->
    <uses-feature android:name="android.hardware.telephony"
                  android:required="false" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <!-- SlideME -->
    <uses-permission android:name="com.slideme.sam.manager.inapp.permission.BILLING" />
    <!-- Skubit -->
    <uses-permission android:name="com.skubit.BILLING" />

    <application>
        <!-- Amazon -->
        <receiver android:name="com.amazon.device.iap.ResponseReceiver">
            <intent-filter>
                <action android:name="com.amazon.inapp.purchasing.NOTIFY"
                        android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY" />
            </intent-filter>
        </receiver>
        <!-- Amazon -->

        <!-- Fortumo -->
        <receiver android:name="mp.MpSMSReceiver">
            <intent-filter>
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            </intent-filter>
        </receiver>

        <service android:name="mp.MpService" />
        <service android:name="mp.StatusUpdateService" />

        <activity android:name="mp.MpActivity"
                  android:configChanges="orientation|keyboardHidden|screenSize"
                  android:theme="@android:style/Theme.Translucent.NoTitleBar" />
        <!-- Fortumo -->
    </application>
    
</manifest>

Demo

For quick start have a look at the demo/app/main-view-model.js file of the demo app to learn how it works.

Otherwise ...

Usage

Include

Include the module in your code-behind:

var FortumoSMS = require('nativescript-fortumo-sms');

Initialize

Initialize the environment:

function onPageLoaded(args) {
    FortumoSMS.init();
}
exports.onPageLoaded = onPageLoaded;

The (optional) object that is submitted to the PayPal.init function has the following structure:

Properties

| Name | Description | | ----- | ----------- | | onActivityResult | [OPTIONAL] Logic for Activity.onActivityResult method of the underlying Android activity that is used to invoke logic for other modules, e.g. | | requestCode | [OPTIONAL] The custom request code to use (e.g. for Activity.onActivityResult Android method). Default: 198612227 |

Start purchase

function buyProduct(args) {
    // configure
    var purchase = FortumoSMS.newPurchase()
        .setId('<PRODUCT-ID>')
        .setName('test product')
        .setSecret('<APP-SECRET>')
        .setDisplayName('A test product')
        .setAmount('1.95')
        .setCurrency('USD');

    // start purchase
    purchase.start(function(cbResult) {
        switch (cbResult.code) {
            case 0:
                // SUCCESS
                break;
                
            case 1:
                // CANCELLED
                break;
                
            case 2:
                // FAILED
                break;
                
            case 3:
                // PENDING
                break;
                
            case -1:
                // "unhandled exception"
                break;
        }
    });
}
exports.buyProduct = buyProduct;

The purchase object that is created by FortumoSMS.newPurchase function has the following structure.

Methods

| Name | Description | | ----- | ----------- | | isConsumable | Gets if the product is consumable or not. Example: var c = purchase.isConsumable(); | | getAmount | Gets the price. Example: var a = purchase.getAmount(); | | getCreditsMultiplier | Gets the multiplier for the credits. Example: var m = purchase.getCreditsMultiplier(); | | getCurrency | Gets the currency. Example: var c = purchase.getCurrency(); | | getId | Gets the product ID. Example: var id = purchase.getId(); | | getName | Gets the product name. Example: var n = purchase.getName(); | | getSecret | Gets the app secret. Example: var s = purchase.getSecret(); | | setAmount | Sets the price. Example: payment.setAmount('1.25'); | | setCreditsMultiplier | Sets the multiplier for the credits. Example: purchase.setCreditsMultiplier(1.23); | | setCurrency | Sets the currency. Example: purchase.setCurrency('USD'); | | setId | Sets the product ID. Example: purchase.setId('<PRODUCT-ID>'); | | setIfConsumable | Sets if the product is consumable or not. Example: purchase.setIfConsumable(true); | | setName | Sets the product name. Example: purchase.setName('My product'); | | setSecret | Sets the app secret. Example: purchase.setSecret('<APP-SECRET>'); | | start | Starts the purchase process. |

start

The callback that is submitted to the purchase.start method receives an object with the following properties:

| Name | Description | | ----- | ----------- | | billing.status | The billing status (if code = 0) | | code | The result code. 0 = success, -1 = unhandled exception, 1 = canceled, 2 = failed, 3 = pending | | credit.amount | The credit amount (if code = 0) | | credit.currency | The credit name (if code = 0) | | message.id | The message ID (if code = 0) | | payment.code | The payment code (if code = 0) | | price.amount | The price amount (if code = 0) | | price.currency | The price currency (if code = 0) | | product.name | The product name (if code = 0) | | service.id | The service ID (if code = 0) | | sku | Sku (if code = 0) | | user.id | The user ID (if code = 0) |

Enhancements

Logging

If you want to get the logging output of the module, you can use FortumoSMS.addLogger function to add a callback that receives a message from the module:

FortumoSMS.addLogger(function(msg) {
    console.log('[nativescript-fortumo-sms]: ' + msg);
});