NativeScript fortumo SMS
A NativeScript module providing access to Fortumo SMS Gateway.
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:
<!-- Open Stores --> <!-- Google --> <!-- Nokia --> <!-- Samsung --> <!-- Fortumo --> <!-- SlideME --> <!-- Skubit --> <!-- Amazon --> <!-- Amazon --> <!-- Fortumo --> <!-- Fortumo -->
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 = ;
Initialize
Initialize the environment:
{ FortumoSMS;}exportsonPageLoaded = 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
{ // configure var purchase = FortumoSMS ; // start purchase purchasestart { };}exportsbuyProduct = 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;