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

capptain-cordova

v1.0.2

Published

Cordova plugin for Capptain

Downloads

4

Readme

#Cordova plugin for Capptain

Introduction

This plugin integrates the Capptain SDK into your Cordova/PhoneGap Application. It supports both reporting and push features.

Please refer to the Capptain SDK for more information about the various Capptain concepts.

Supported Platforms

  • iOS
  • Android

Installation

To install the plugin, just add it to your Cordova project using your proper Capptain credentials through Cordova variables.

cd <your project>
cordova plugin add <capptain plugin directory> --variable KEY=<value>

Generic Variables

  • $CAPPTAIN_ENABLE_LOG : true|false, enable both plugin and capptain native logs
  • $CAPPTAIN_REDIRECT_URL : the url schemes of your application when using redirect actions in your campaign. Must be the url prefix without :// (ex: myapp to handle urls such as myapp://shop)

iOS Variables

  • $CAPPTAIN_IOS_APP_ID : the Capptain ID of your iOS application
  • $CAPPTAIN_IOS_SDK_KEY : the Capptain sdk key
  • $CAPPTAIN_IOS_REACH_ICON : the icon used for reach notification : must be the name of the resource with its extension (ex: icon.png)

Android Variables

  • $CAPPTAIN_ANDROID_APP_ID : the Capptain ID of your Android application
  • $CAPPTAIN_ANDROID_REACH_ICON : the icon used for reach notification : must be the name of the resource without any extension, nor drawable prefix (ex: icon)
  • $CAPPTAIN_GOOGLE_PROJECT_NUMBER : the project number used as the GCM (Google Cloud Messaging) sender ID

To remove the plugin,

cordova plugin rm cordova-plugin-ms-capptain

Methods

Once the deviceready event has been triggered by the Cordova framework, a Capptain object is available to interact with the native Capptain SDK.

  • Capptain.startActivity
  • Capptain.endActivity
  • Capptain.sendAppInfo
  • Capptain.startJob
  • Capptain.endJob
  • Capptain.sendEvent
  • Capptain.onOpenURL
  • Capptain.registerForRemoteNotification
  • Capptain.getStatus

###Capptain.startActivity

Start a new activty with the corresponding extra infos object.

Capptain.startActivity(_activityName, _extraInfos,[ _success], [_failure]);

#####Params

  • _activityName: the name of the activity
  • _extraInfos: a json object containing the extra infos attached to this activity

###Capptain.endActivity Ends the current Actvity. Would trigger a new session on the next startActivity

Capptain.endActivity([ _success], [_failure]);

###Capptain.sendEvent Send an event with the corresponding extra infos object.

sendEvent(_eventName, _extraInfos,[ _success], [_failure]);

#####Params

  • _eventName: the name of the event
  • _extraInfos: a json object containing the extra infos attached to this event

###Capptain.startJob Start an new job with the corresponding extra infos object.

Capptain.startJob(_jobName, _extraInfos,[ _success], [_failure]);

#####Params

  • _jobName: the name of the job
  • _extraInfos: a json object containing the extra infos attached to this job

###Capptain.endJob End a job previously created by startJob

Capptain.endJob(_jobName,[ _success], [_failure]);

#####Params

  • _jobName: the name of the job

###Capptain.sendAppInfo Send App Infos atttached to the currente device.

Capptain.sendAppInfo( _appInfos,[ _success], [_failure]);

#####Params

  • _appInfos: the json object containing the app infos to be sent

###Capptain.onOpenURL Set an event handler when an application specific URL is triggered (from a push campaign for example). The URL scheme must match the one defined in the redirect_url setting

Capptain.onOpenURL( _urlHandler,[ _success], [_failure]);

#####Params

  • _urlHandler: the handler that is passed the url that has been triggerd

#####Example

	Capptain.onOpenURL(function(_url) {
			console.log("user triggered url/action "+_url);
		});

###Capptain.registerForPushNotification Register the application to receive push notifications on iOS (this function does nothing on the other platforms)

Capptain.registerForPushNotification( [_success], [_failure]);

###Capptain.getStatus Returns information about the Capptain library

Capptain.getStatus( _statusCallback, [_failure]);

#####Params

  • _statusCallback: the handler that is passed a json object containing information about the Capptain library

#####Example

	Capptain.getStatus(function(_info) {
		    console.log("Capptain SDK Version : "+_info.capptainVersion);
		      console.log("Capptain plugin Version : "+_info.pluginVersion);
		});

Running the sample Application

To easily play around with the plugin, a sample application (w/ unit testing) is available in the sample folder.

MAC OS/X

  • Edit setup.sh with your own credentials
export CAPPTAIN_IOS_APP_ID=<APP_ID_IOS>
export CAPPTAIN_IOS_SDK_KEY=<SDK_KEY>
export CAPPTAIN_ANDROID_APP_ID=<APP_ID_ANDROID>
export CAPPRAIN_ANDROID_GOOGLE_PROJECT_NUMBER=<GOOGLE_PROJECT_NUMBER>
  • Create the sample project by launching setup.sh
sh setup.sh
  • Go to the directory where the app has been created
cd ~/CapptainCordova
  • Launch one of the following command
cordova run android
cordova emulate ios
cordova run ios device

Windows

The process is similar, just edit/run the setup.batfile. Obviously, only the Android platform is supported on Windows.

Advance Testing

Campaign

In-App campaign should work directly, and redirection can be tested by using action URL beginning with "mytest://"

Native Push Testing

Native notification requires some additional configuration of your Capptain app (cf. the Capptain Documentation for reference)

  • Import a Native Push Certificate into your Capptain console (iOS)
  • Set the Server Key from your Google Cloud Messaging enabled app (Android)

History

1.0.2

  • Replaced hooks with Cordova Variables
  • Using cordova-plugin-ms-capptain as the new plugin Id

1.0.1

  • Updated Capptain iOS SDK to 1.16.2
  • Updated Capptain Android SDK to 2.4.1
  • Using swizzling to remove ld warning on iOS
  • Adding deferred Remote Notification

1.0.0

  • Initial Release