import { SecurityContext } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; private sanitizer: DomSanitizer; downloadCSV() { let blob = new Blob([yourdata], { type: 'text/csv' }); let urlPath = this.sanitizer.sanitize(SecurityContext.URL, this.sanitizer.bypassSecurityTrustResourceUrl(window.URL.createObjectURL(blob))); let tempLink = document.createElement('a'); tempLink.href = urlPath; tempLink.setAttribute('download', 'download.csv'); tempLink.click(); }
Angular
Google Android Play Store Target API Requirement Change
Hello Google Play Developer,
This is a reminder that starting November 1, 2019, updates to apps and games on Google Play will be required to target Android 9 (API level 28) or higher. After this date, the Play Console will prevent you from submitting new APKs with a targetSdkVersion less than 28.
Configuring your app to target a recent API level ensures that users benefit from significant security and performance improvements, while still allowing your app to run on older Android versions (down to the minSdkVersion).
Android 9 (API level 28) introduces a number of changes to the Android system. The following behavior changes apply exclusively to apps that are targeting API level 28 or higher. Apps that set targetSdkVersion to API level 28 or higher must modify their apps to support these behaviors properly, where applicable to the app.
To target the api in your Cordova app set these min and target version in config.xml
<preference name="android-minSdkVersion" value="23" /> <preference name="android-targetSdkVersion" value="28" />
How To Find Valid Email Address in JavaScript Regex
How To Find Validate Email Address format in JavaScript Regex:
const EMAIL_REGEX = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; let email = "m.e@my.email"; alert( EMAIL_REGEX.test(email));
How to Implement Merge Sort in JavaScript
How to Implement Merge Sort in JavaScript the easy way.
// Split the array into halves and merge them recursively function mergeSort (arr) { if (arr.length === 1) { // return once we hit an array with a single item return arr } const middle = Math.floor(arr.length / 2) // get the middle item of the array rounded down const left = arr.slice(0, middle) // items on the left side const right = arr.slice(middle) // items on the right side return merge( mergeSort(left), mergeSort(right) ) } // compare the arrays item by item and return the concatenated result function merge (left, right) { let result = [] let indexLeft = 0 let indexRight = 0 while (indexLeft < left.length && indexRight < right.length) { if (left[indexLeft] < right[indexRight]) { result.push(left[indexLeft]) indexLeft++ } else { result.push(right[indexRight]) indexRight++ } } return result.concat(left.slice(indexLeft)).concat(right.slice(indexRight)) } const list = [2, 5, 1, 3, 7, 2, 3, 8, 6, 3]; console.log(mergeSort(list)) // [ 1, 2, 2, 3, 3, 3, 5, 6, 7, 8 ];
How To Find Duplicates in an Array in JS
function findDupes(arr) { for (let i = 0; i < arr.length; i++){ if (hash[arr[i]] === "true"){ dupes.push(arr[i]); } hash[arr[i]] = "true" ; } console.log(dupes); } let arr = [1, 5, 6, 6, 6, 5 ,6 ,7 ,3, 2, 1, 3]; let dupes = []; let hash = {}; findDupes(arr);
iOS Deprecated API Usage Warning Ionic using UIWebView
Apple will no longer support web apps that use UIWebView. The apps and libraries need to be migrated to use WkWebView.
The latest Ionic already uses WkWebView, but several Cordova plugins still rely on UIWebView which is a problem.
https://ionicframework.com/docs/v3/wkwebview/
If you’re using Ionic you need to upgrade to iOS Cordova 5
cordova platform remove ios cordova platform add ios@5.0.0
Also you might need to remove additional plugins that use UIWebView such as inappbrowser.
cordova plugin rm cordova-plugin-inappbrowser
More information about the breaking changes can be found here:
https://cordova.apache.org/news/2018/08/01/future-cordova-ios-webview.html