Skip to content

Instantly share code, notes, and snippets.

Avatar
🗺️

Hans Knöchel hansemannn

🗺️
View GitHub Profile
@hansemannn
hansemannn / example-ios.js
Created Jan 13, 2021
iOS In-App-Billing Module
View example-ios.js
var IAP = require('ti.iap');
var PRODUCT_IDENTIFIER = 'YOUR_PRODUCT_IDENTIFIER';
var SHARED_SECRET = 'YOUR_SHARED_SECRET';
var win = Ti.UI.createWindow({ backgroundColor: '#fff', title: 'IAP Demo' });
win.addEventListener('open', onOpen);
// Retrieve products info
var btn1 = Ti.UI.createButton({ title: 'Retrieve products info', top: 50 });
@hansemannn
hansemannn / README.md
Created Oct 5, 2020
Titanium iOS In-App-Purchase / Storekit
View README.md

Titanium In-App-Purchasing

Support the native in-app-purchasing API's in Titanium.

Example

var IAP = require('ti.iap');

var PRODUCT_IDENTIFIER = 'YOUR_PRODUCT_IDENTIFIER';
@hansemannn
hansemannn / app.js
Created Sep 25, 2020
Example of using the newest Stripe SDK for iOS/Android in Appcelerator Titanium (contact via @hans on TiSlack.org)
View app.js
var Stripe = require('ti.stripe');
var win = Ti.UI.createWindow({
backgroundColor: '#fff',
layout: 'vertical'
});
win.addEventListener('open', initialize);
win.open();
@hansemannn
hansemannn / config-manager.js
Created Aug 21, 2020
Firebase remote config example for Axway Titanium
View config-manager.js
import TiFirebaseConfig from 'firebase.config';
export default class ConfigManager {
static fetch () {
return new Promise(resolve => {
const lastVersions = Ti.App.Properties.getList('kMyAppLastVersions', []);
const lastVersionLegacy = Ti.App.Properties.getString('lastVersion', null);
// Migrate prior updates
@hansemannn
hansemannn / push-manager.js
Created Oct 15, 2019
Handle iOS push notifications in Appcelerator Titanium
View push-manager.js
import FirebaseMessaging from 'firebase.cloudmessaging';
export default class PushManager {
listenForPushNotifications() {
// Called when the Firebase token is ready
FirebaseMessaging.addEventListener('didRefreshRegistrationToken', event => {
const fcmToken = event.fcmToken;
// Update push token here …
@hansemannn
hansemannn / loader.js
Created May 28, 2019
A cross platform modal loading indicator to use in Appcelerator Titanium
View loader.js
import TiAnimation from 'ti.animation';
/**
* A loader class to show a modal loading indicator
* above the current context (even above modal).
*
* Author: Hans Knöchel
*
*/
export default class Loader {
@hansemannn
hansemannn / deep-linking-manager.js
Created May 20, 2019
Titanium Deep Linking Manager (iOS)
View deep-linking-manager.js
export default class DeepLinkingManager {
constructor () {
this.handledLinks = {};
this.activityType = 'io.lambus.app.universalLink';
const activity = Ti.App.iOS.createUserActivity({
activityType: this.activityType
});
@hansemannn
hansemannn / ti.speech.example.js
Created Apr 8, 2019
Realtime Speech Recognition in Titanium
View ti.speech.example.js
var TiSpeech = require('ti.speech');
TiSpeech.initialize('en_US'); // locale is optional
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
var currentValue = '';
View handleData.swift
func handleData() {
let jsonData: [String: Any]
let text = String(describing: self.data)
// JSON serialisation can fail, use do-catch (like try-catch in
// to cope with possible failuresJava/C)
do {
// JSON data is copied into a key/value dictionary
jsonData = try JSONSerialization.jsonObject(with: self.data, options: [.mutableContainers]) as! [String: Any]
} catch {
return debugPrint("Error occurred: \(error.localizedDescription)")
@hansemannn
hansemannn / cropping-manager.js
Created Mar 14, 2019
An example of cropping images cross-platform on Titanium.
View cropping-manager.js
/**
* Crops a given image URL to an optional aspect ratop (square by default).
*
* Example:
*
* const image = await ImageCroppingManager.crop(myImageURL);
*
*/
export default class ImageCroppingManager {
You can’t perform that action at this time.