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

gamification-ionic

v1.0.4

Published

SDK for gamification for ionic

Downloads

143

Readme

Gamification for android & ios platform

This package provide integration with gamification provided by The Logical Banya.

Installation

You can install this package using npm:

npm i gamification-ionic

Install package for screen lock orientation:

npm install @capacitor/screen-orientation
import {ScreenOrientation} from '@capacitor/screen-orientation'

Usage

1.create new page and import Gamification package & pass configuration to init method.

import package

import Gamification from "gamification-ionic";

initialize config

const config = {
  baseUrl: "",
  clientID: "",
  key: "",
  userID: "",
  username: "",
  keyString: "",
  appId: 'app' /* pass div id in used index.html like  <body> <div id="app"></div>< /body> */
  utm_param1: 'ionic' // optional parameters 
  utm_param2 :'' // optional parameters 
  utm_param3 :'' // optional parameters 
  utm_param4 :'' // optional parameters 
  style: {height: '100vh'} // optional parameters you can pass styles here height,width,left,zIndex,top
  
};
Gamification.init(config);
Required parameters

baseUrl: "",
clientID: "",
key: "",
userID: "",
username: "",
keyString: "",
utm_param1: 'ionic'

Take above parameters from provider.

Create new method to open & close application.


const isOpen = ref(false);

const openApp = async () => {
  //this code if need  screen rotation prevents start
  try {
    await ScreenOrientation.lock({orientation: 'portrait'});
  } catch (e) {
    console.error(e.message)
  }
  //this code for screen rotation prevents end

  await Gamification.run();
  isOpen.value = true;
}

// for close gamification window
window.addEventListener('message', async (event) => {
  // Check origin if needed for security
  const {data} = event;
  if (data === 'close-app') {
    await Gamification.close();
    await ScreenOrientation.unlock();
  }
  // Handle the received data
});

Create method for closing application.

const closeApp =async () => {
  Gamification.close();
  await ScreenOrientation.unlock();
}

Here is an example of implementation.

<template>
  <ion-page>
    <ion-content :fullscreen="true">
      <div style="padding: 10px">
        <IonButton @click="openApp" type="button" mode="md" color="primary">
          IONIC Test
        </IonButton>
      </div>
    </ion-content>
  </ion-page>
</template>

<script setup>
import {IonButton, IonContent, IonPage} from '@ionic/vue';
import Gamification from "gamification-ionic";
import {ref} from "vue";
import {ScreenOrientation} from '@capacitor/screen-orientation';

Gamification.init({
  baseUrl: "",
  clientID: "",
  key: "",
  userID: "",
  username: "",
  keyString: "",
  appId: 'app', /* pass div id in used index.html like  <body> <div id="app"></div>< /body> */
  utm_param1: 'ionic'
  // style: {
  //   height: 'calc(100vh - 70px)',
  //   top: '70px',
  // }
});
const isOpen = ref(false);

const openApp = async () => {
//this code if need  screen rotation prevents start
  try {
    await ScreenOrientation.lock({orientation: 'portrait'});
  } catch (e) {
    console.error(e.message)
  }
//this code if need  screen rotation prevents end

  await Gamification.run();
  isOpen.value = true;

}

  // for close gamification window
window.addEventListener('message', async (event) => {
  // Check origin if needed for security
  const {data} = event;
  if (data === 'close-app') {
    await Gamification.close();
    await ScreenOrientation.unlock();
  }
  // Handle the received data
});
</script>

    

Also you can pass another optional parameters

2.utm_param2 <br>
3.utm_param3 <br>
4.utm_param4 <br>
5.style: {
    height: '100vh',
    width:100%,
} // optional parameters you can pass to style key: height,width,left,zIndex,top<br>