Skip to content

Instantly share code, notes, and snippets.

View EddyVerbruggen's full-sized avatar
🔌
plugged in

Eddy Verbruggen EddyVerbruggen

🔌
plugged in
View GitHub Profile
@EddyVerbruggen
EddyVerbruggen / iOS8 Beta Phonegap fix
Last active December 8, 2018 05:28
iOS8 Beta Phonegap fix: manually set the navigator.userAgent
// temp fix for iOS8 beta 1 (fixed in beta 2), add it after the reference to cordova.js
if (navigator.userAgent === undefined) {
navigator.__defineGetter__('userAgent', function() {
return("Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit");
});
}
Run this in your Mac Terminal (assuming you have the Ionic CLI):
----------------------------------------------------------------
ionic start wkwebviewpolyfilltest
cd wkwebviewpolyfilltest
ionic setup sass
ionic platform add ios
ionic plugin add https://github.com/EddyVerbruggen/cordova-plugin-wkwebview
ionic build
----------------------------------------------------------------
@EddyVerbruggen
EddyVerbruggen / Tweet-a-selfie
Created April 13, 2015 06:01
Tweet a selfie with the Cordova SocialSharing plugin
navigator.camera.getPicture(
function(base64EncodedImg) {
// wrap in a timeout so the native view of SocialSharing doesn't collide with the one from the camera plugin
setTimeout(function() {
window.plugins.socialsharing.shareViaTwitter('Check my latest selfie. I\'m awesome!', 'data:image/jpg;base64,'+base64EncodedImg, null, null, null);
}, 500);
},
function(msg) {
alert("Error: " + msg);
},
@EddyVerbruggen
EddyVerbruggen / yourapp.plist
Last active September 11, 2015 19:03
Whitelist your server for iOS9 non-HTTPS communication
<!--
When building with XCode 7 (iOS9 SDK), Apple restricts communication to SSL servers only.
See https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/
You can override this if you need to.
If you know which servers your app talks to, look for 'NSExceptionDomains' on the page above.
But if you need to whitelist everything (not recommended) add this to your app's .plist:
-->
angular.module('sfViewCtrlDirective', [])
.directive('open', OpenDirective);
function OpenDirective() {
return {
restrict: 'A',
link: function($scope, $element, $attr) {
console.log('device is ready');
$element.on('click', function() {

A Very Rough Guide to Firebase and NativeScript

Create Plugin

  • mkdir nativescript-firebase
  • cd nativescript-firebase
  • npm init
  • tns init
  • mkdir -p platforms/ios
  • touch platforms/ios/Podfile
@ivanbuhov
ivanbuhov / app.css
Last active January 4, 2017 15:05
Proof of concept NativeScript app whcih is using HomeKit API
.title {
font-size: 30;
horizontal-align: center;
margin:20;
}
button {
font-size: 42;
horizontal-align: center;
}
@EddyVerbruggen
EddyVerbruggen / app.js
Last active June 20, 2016 06:20
NativeScript 3D Touch shortcut icons
// Open your app's main js file and add this handler (delimited by 'START 3DTouch wiring' and 'END 3DTouch wiring').
// Then tweak the handling of 'shortcutItem.type' to your liking (here I'm deeplinking 'compose' to the 'compose' page and ignore other shortcut types).
var application = require("application");
application.cssFile = "./app.css";
application.mainModule = "main-page";
// START 3DTouch wiring
var MyDelegate = (function (_super) {
// In case you embed a webview in a native app and the native app has a navigation bar you may find
// swiping up from the webview to the header (and releasing your finger on the header) will not fire
// a 'touchend' event on the webview.
//
// This code fixes it in a way where we listen for 'touchmove' events and fire a 'touchend' event
// programmatically in case the user leaves the webview at the top (negative Y coordinate):
document.addEventListener("touchmove", function(e) {
if (e.changedTouches[0].pageY < 0) {
e.preventDefault();
@NathanWalker
NathanWalker / app.component.ts
Last active December 13, 2017 15:54
NativeScript: Wire up RadSideDrawer from 'nativescript-telerik-ui' with Angular2 taking full advantage of Router
// angular
import {Component} from '@angular/core';
@Component({
moduleId: module.id,
selector: 'app',
template: `
<StackLayout>
<page-router-outlet></page-router-outlet>
</StackLayout>