This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
(function() { | |
var intervalID = null; | |
function startCheckingNetworkConnection() { | |
intervalID = setInterval(function() { | |
var networkState = navigator.connection.type; | |
var isWifi = networkState == Connection.WIFI; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
---------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I'm not saying this is the best solution, it's just a temp fix which works in my case to solve | |
// the issue where a passed in url is not propagated to the handleOpenURL js function upon | |
// coldstart on iOS Cordova 3.7.0. | |
// Stay tuned on this issue for a better fix: https://issues.apache.org/jira/browse/CB-7606 | |
// replace processOpenUrl in CDVViewController.m by this: | |
- (void)processOpenUrl:(NSURL*)url pageLoaded:(BOOL)pageLoaded | |
{ | |
NSString* readyState = [webView stringByEvaluatingJavaScriptFromString:@"document.readyState"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inside your Activity class onCreate method add and invoke this method. | |
// Note that you can plug this into any Android project, you don't need to build with SDK 21 to be able to compile | |
private void setStatusBarColor() { | |
if (Build.VERSION.SDK_INT >= 21) { | |
final Window window = getWindow(); | |
// Method and constants not available on all SDKs but we want to be able to compile this code with any SDK | |
window.clearFlags(0x04000000); // SDK 19: WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); | |
window.addFlags(0x80000000); // SDK 21: WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
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: | |
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { HomeKit } from "nativescript-homekit"; | |
import { prompt, PromptResult } from "ui/dialogs"; | |
// instantiate the plugin's main Class | |
const homeKit = new HomeKit(); | |
// ask the user for a name and add it to HomeKit | |
prompt("Name the home").then((promptResult: PromptResult) => { | |
if (promptResult.result) { | |
homekit.addHome(promptResult.text).then( |
OlderNewer