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
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
// 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
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( |
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
// the home you created earlier | |
let homeName = home.name; | |
// ask the user for a name and add it to HomeKit | |
prompt(`Name the room to add to ${homeName}`).then((promptResult: PromptResult) => { | |
if (promptResult.result) { | |
homekit.addRoomToHome(promptResult.text, homeName).then( | |
(room: Room) => console.log(`Added room ${room.name} to home ${homeName}`), | |
err => alert(err) | |
); |
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
// start searching | |
homekit.startSearchingForAccessories( | |
// event handler which is triggered when a new accessory is found | |
(accessory: Accessory) => { | |
console.log(`New accessory found: ${accessory.name}`); | |
// once found you can assign it to a home | |
homekit.addAccessoryToHome(accessory.name, homeName) | |
.then(added => console.log(`Added? ${added}`)); | |
}, | |
// event handler which is triggered when an accessory was removed |
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 a few Classes we're gonna use | |
import { Accessory, Service, Characteristic } from 'nativescript-homekit'; | |
// given an accessory.. | |
let accessory: Accessory = myPreviouslyFoundAccessory; | |
// .. you can now list its services.. | |
accessory.services.forEach((s: Service) => { | |
console.log(`Service ${s.name} of type ${s.type} has ${s.characteristics.length} characteristics`); |
OlderNewer