IntercomBridge.m update for Intercom Cordova Ionic

Recently I had to update the intercom bridge file manually because the cordova intercom plugin appears incompatible with the latest ios sdk. Here are the changes:

//IntercomBridge.m

#import "IntercomBridge.h"
#import "AppDelegate+IntercomPush.h"
#import "ICMHelpCenterCollection+DictionaryConversion.h"
#import "ICMHelpCenterArticleSearchResult+DictionaryConversion.h"
#import "ICMHelpCenterCollectionContent+DictionaryConversion.h"
#import 

@interface Intercom (Cordoava)
+ (void)setCordovaVersion:(NSString *)v;
@end

@implementation IntercomBridge : CDVPlugin

- (void)pluginInitialize {
    [Intercom setCordovaVersion:@"12.4.0"];
    #ifdef DEBUG
        [Intercom enableLogging];
    #endif

    //Get app credentials from config.xml or the info.plist if they can't be found
    NSString* apiKey = self.commandDelegate.settings[@"intercom-ios-api-key"] ?: [[NSBundle mainBundle] objectForInfoDictionaryKey:@"IntercomApiKey"];
    NSString* appId = self.commandDelegate.settings[@"intercom-app-id"] ?: [[NSBundle mainBundle] objectForInfoDictionaryKey:@"IntercomAppId"];

    [Intercom setApiKey:apiKey forAppId:appId];
}

- (void)registerIdentifiedUser:(CDVInvokedUrlCommand*)command {
    NSDictionary* options = command.arguments[0];
    NSString* userId      = options[@"userId"];
    NSString* userEmail   = options[@"email"];

    if ([userId isKindOfClass:[NSNumber class]]) {
        userId = [(NSNumber *)userId stringValue];
    }

    ICMUserAttributes *userAttributes = [ICMUserAttributes new];
    
    if (userId.length > 0 && userEmail.length > 0) {
        userAttributes.userId = userId;
        userAttributes.email = userEmail;
    } else if (userId.length > 0) {
        userAttributes.userId = userId;
    } else if (userEmail.length > 0) {
        userAttributes.email = userEmail;
    } else {
        NSLog(@"[Intercom-Cordova] ERROR - No user registered. You must supply an email, a userId or both");
        [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR]
                                    callbackId:command.callbackId];
        return;
    }
    
    [Intercom loginUserWithUserAttributes:userAttributes success:nil failure:nil];
    [self sendSuccess:command];
}

- (void)registerUnidentifiedUser:(CDVInvokedUrlCommand*)command {
    [Intercom loginUnidentifiedUserWithSuccess:nil failure:nil];
    [self sendSuccess:command];
}

- (void)logout:(CDVInvokedUrlCommand*)command {
    [Intercom logout];
    [self sendSuccess:command];
}

- (void)setUserHash:(CDVInvokedUrlCommand*)command {
    NSString *hmac = command.arguments[0];

    [Intercom setUserHash:hmac];
    [self sendSuccess:command];
}

- (void)updateUser:(CDVInvokedUrlCommand*)command {
    NSDictionary* attributesDict = command.arguments[0];
    [Intercom updateUser:[self userAttributesForDictionary:attributesDict] success:nil failure:nil];
    [self sendSuccess:command];
}

- (void)logEvent:(CDVInvokedUrlCommand*)command {
    NSString *eventName = command.arguments[0];
    NSDictionary *metaData = command.arguments[1];

    if ([metaData isKindOfClass:[NSDictionary class]] && metaData.count > 0) {
        [Intercom logEventWithName:eventName metaData:metaData];
    } else {
        [Intercom logEventWithName:eventName];
    }
    [self sendSuccess:command];
}

- (void)unreadConversationCount:(CDVInvokedUrlCommand*)command {
    NSUInteger count = [Intercom unreadConversationCount];
    CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsNSUInteger:count];
    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

- (void)displayMessenger:(CDVInvokedUrlCommand*)command {
    [Intercom presentIntercom];

    [self sendSuccess:command];
}

- (void)displayMessageComposer:(CDVInvokedUrlCommand*)command {
    [Intercom presentMessageComposer:nil];
    [self sendSuccess:command];
}

- (void)displayMessageComposerWithInitialMessage:(CDVInvokedUrlCommand*)command {
    NSString *initialMessage = command.arguments[0];
    [Intercom presentMessageComposer:initialMessage];
    [self sendSuccess:command];
}

- (void)displayConversationsList:(CDVInvokedUrlCommand*)command {
    NSLog(@"[Intercom-Cordova] WARNING - displayConversationsList is deprecated. Please use displayMessenger instead.");
    [Intercom presentIntercom];

    [self sendSuccess:command];
}

- (void)displayHelpCenter:(CDVInvokedUrlCommand*)command {
  //  [Intercom presentHelpCenter];

    [self sendSuccess:command];
}

- (void)displayHelpCenterCollections:(CDVInvokedUrlCommand*)command {
    NSDictionary *args = command.arguments[0];
    NSArray* collectionIds = args[@"collectionIds"];
  //  [Intercom presentHelpCenterCollections:collectionIds];
    [self sendSuccess:command];
}

- (void)fetchHelpCenterCollections:(CDVInvokedUrlCommand*)command {
    [Intercom fetchHelpCenterCollectionsWithCompletion:^(NSArray * _Nullable collections, NSError * _Nullable error) {
        if (error) {
            CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsNSInteger:error.code];
            [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
        } else {
            NSMutableArray *array = [[NSMutableArray alloc] init];
            for (ICMHelpCenterCollection *collection in collections) {
                [array addObject:[collection toDictionary]];
            }
            NSString *jsonString = [self stringValueForDictionaries:(NSArray *)array];
            CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString];
            [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
        }
    }];
}

- (void)fetchHelpCenterCollection:(CDVInvokedUrlCommand*)command {
    NSString *collectionId = command.arguments[0];
    [Intercom fetchHelpCenterCollection:collectionId withCompletion:^(ICMHelpCenterCollectionContent * _Nullable collectionContent, NSError * _Nullable error) {
        if (error) {
            CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsNSInteger:error.code];
            [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
        } else {
            NSString *jsonString = [self stringValueForDictionary:[collectionContent toDictionary]];
            CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString];
            [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
        }
    }];
}

- (void)searchHelpCenter:(CDVInvokedUrlCommand*)command {
    NSString *searchTerm = command.arguments[0];
    [Intercom searchHelpCenter:searchTerm withCompletion:^(NSArray * _Nullable articleSearchResults, NSError * _Nullable error) {
        if (error) {
            CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsNSInteger:error.code];
            [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
        } else {
            NSMutableArray *array = [[NSMutableArray alloc] init];
            for (ICMHelpCenterArticleSearchResult *articleSearchResult in articleSearchResults) {
                [array addObject:[articleSearchResult toDictionary]];
            }
            NSString *jsonString = [self stringValueForDictionaries:(NSArray *)array];
            CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString];
            [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
        }
    }];
}

- (void)hideIntercom:(CDVInvokedUrlCommand*)command {
    [Intercom hideIntercom];
    [self sendSuccess:command];
}

- (void)setLauncherVisibility:(CDVInvokedUrlCommand*)command {
    NSString *visibilityString = command.arguments[0];
    BOOL visible = NO;
    if ([visibilityString isEqualToString:@"VISIBLE"]) {
        visible = YES;
    }
    [Intercom setLauncherVisible:visible];
    [self sendSuccess:command];
}

- (void)setInAppMessageVisibility:(CDVInvokedUrlCommand*)command {
    NSString *visibilityString = command.arguments[0];
    BOOL visible = NO;
    if ([visibilityString isEqualToString:@"VISIBLE"]) {
        visible = YES;
    }
    [Intercom setInAppMessagesVisible:visible];
    [self sendSuccess:command];
}

- (void)registerForPush:(CDVInvokedUrlCommand*)command {
    UIApplication *application = [UIApplication sharedApplication];
    [application registerUserNotificationSettings:[UIUserNotificationSettings
                                 settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)
                                       categories:nil]];
    [application registerForRemoteNotifications];
    [self sendSuccess:command];
}

- (void)sendPushTokenToIntercom:(CDVInvokedUrlCommand*)command {
  NSLog(@"[Intercom-Cordova] INFO - sendPushTokenToIntercom called");
}

- (void)displayCarousel:(CDVInvokedUrlCommand*)command {
  NSString *carouselId = command.arguments[0];
    [Intercom presentContent:[IntercomContent carouselWithId:carouselId]];
    [self sendSuccess:command];
}

- (void)displayArticle:(CDVInvokedUrlCommand*)command {
  NSString *articleId = command.arguments[0];
    [Intercom presentContent:[IntercomContent articleWithId:articleId]];
    [self sendSuccess:command];
}

- (void)displaySurvey:(CDVInvokedUrlCommand*)command {
  NSString *surveyId = command.arguments[0];
    [Intercom presentContent:[IntercomContent surveyWithId:surveyId]];
    [self sendSuccess:command];
}

- (void)setBottomPadding:(CDVInvokedUrlCommand*)command {
    double bottomPadding = [[command.arguments objectAtIndex:0] doubleValue];
    [Intercom setBottomPadding:bottomPadding];
    [self sendSuccess:command];
}

#pragma mark - User attributes

- (ICMUserAttributes *)userAttributesForDictionary:(NSDictionary *)attributesDict {
    ICMUserAttributes *attributes = [ICMUserAttributes new];
    if ([self stringValueForKey:@"email" inDictionary:attributesDict]) {
        attributes.email = [self stringValueForKey:@"email" inDictionary:attributesDict];
    }
    if ([self stringValueForKey:@"user_id" inDictionary:attributesDict]) {
        attributes.userId = [self stringValueForKey:@"user_id" inDictionary:attributesDict];
    }
    if ([self stringValueForKey:@"name" inDictionary:attributesDict]) {
        attributes.name = [self stringValueForKey:@"name" inDictionary:attributesDict];
    }
    if ([self stringValueForKey:@"phone" inDictionary:attributesDict]) {
        attributes.phone = [self stringValueForKey:@"phone" inDictionary:attributesDict];
    }
    if ([self stringValueForKey:@"language_override" inDictionary:attributesDict]) {
        attributes.languageOverride = [self stringValueForKey:@"language_override" inDictionary:attributesDict];
    }
    if ([self dateValueForKey:@"signed_up_at" inDictionary:attributesDict]) {
        attributes.signedUpAt = [self dateValueForKey:@"signed_up_at" inDictionary:attributesDict];
    }
    if ([self stringValueForKey:@"unsubscribed_from_emails" inDictionary:attributesDict]) {
        attributes.unsubscribedFromEmails = [self stringValueForKey:@"unsubscribed_from_emails" inDictionary:attributesDict];
    }
    if (attributesDict[@"custom_attributes"]) {
        attributes.customAttributes = attributesDict[@"custom_attributes"];
    }
    if (attributesDict[@"companies"]) {
        NSMutableArray *companies = [NSMutableArray new];
        for (NSDictionary *companyDict in attributesDict[@"companies"]) {
            [companies addObject:[self companyForDictionary:companyDict]];
        }
        attributes.companies = companies;
    }
    return attributes;
}

- (ICMCompany *)companyForDictionary:(NSDictionary *)attributesDict {
    ICMCompany *company = [ICMCompany new];
    if ([self stringValueForKey:@"company_id" inDictionary:attributesDict]) {
        company.companyId = [self stringValueForKey:@"company_id" inDictionary:attributesDict];
    }
    if ([self stringValueForKey:@"name" inDictionary:attributesDict]) {
        company.name = [self stringValueForKey:@"name" inDictionary:attributesDict];
    }
    if ([self dateValueForKey:@"created_at" inDictionary:attributesDict]) {
        company.createdAt = [self dateValueForKey:@"created_at" inDictionary:attributesDict];
    }
    if ([self numberValueForKey:@"monthly_spend" inDictionary:attributesDict]) {
        company.monthlySpend = [self numberValueForKey:@"monthly_spend" inDictionary:attributesDict];
    }
    if ([self stringValueForKey:@"plan" inDictionary:attributesDict]) {
        company.plan = [self stringValueForKey:@"plan" inDictionary:attributesDict];
    }
    if (attributesDict[@"custom_attributes"]) {
        company.customAttributes = attributesDict[@"custom_attributes"];
    }
    return company;
}

- (NSString *)stringValueForKey:(NSString *)key inDictionary:(NSDictionary *)dictionary {
    NSString *value = dictionary[key];
    if ([value isKindOfClass:[NSString class]]) {
        return value;
    }
    if ([value isKindOfClass:[NSNumber class]]) {
        return [NSString stringWithFormat:@"%@", value];
    }
    if ([value isKindOfClass:[NSNull class]]) {
        return [ICMUserAttributes nullStringAttribute];
    }
    return nil;
}

- (NSString *)stringValueForDictionaries:(NSArray *)dictionaries {
    NSError *error;
    NSString *jsonString;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionaries options:0 error:&error];
    if (!jsonData) {
        NSLog(@"Got an error: %@", error);
    } else {
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    }
    return jsonString;
}


- (NSString *)stringValueForDictionary:(NSDictionary *)dictionary {
    NSError *error;
    NSString *jsonString;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:&error];
    if (!jsonData) {
        NSLog(@"Got an error: %@", error);
    } else {
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    }
    return jsonString;
}

- (NSNumber *)numberValueForKey:(NSString *)key inDictionary:(NSDictionary *)dictionary {
    NSNumber *value = dictionary[key];
    if ([value isKindOfClass:[NSNumber class]]) {
        return value;
    }
    if ([value isKindOfClass:[NSNull class]]) {
        return [ICMUserAttributes nullNumberAttribute];
    }
    return nil;
}

- (NSDate *)dateValueForKey:(NSString *)key inDictionary:(NSDictionary *)dictionary {
    NSNumber *value = dictionary[key];
    if ([value isKindOfClass:[NSNumber class]]) {
        return [NSDate dateWithTimeIntervalSince1970:[value doubleValue]];
    }
    if ([value isKindOfClass:[NSNull class]]) {
        return [ICMUserAttributes nullDateAttribute];
    }
    return nil;
}


#pragma mark - Private methods

- (void)sendSuccess:(CDVInvokedUrlCommand*)command {
    CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

@end




Is Angular better than React?

Angular and React are both great front-end frameworks used for building dynamic web applications. While both have their own set of benefits, Angular has a slight edge over React in certain areas.

Here are a few reasons why Angular is a little better than React:

Comprehensive framework: Angular is a full-featured framework that provides many features out of the box, such as built-in routing, form validation, and dependency injection. React, on the other hand, is a lightweight library that only provides the essential tools needed to build a web application.

Two-way data binding: Angular’s two-way data binding allows for efficient data synchronization between the model and the view, making it easier to manage complex applications. React, on the other hand, uses a one-way data flow, which can sometimes lead to more complex code and a steeper learning curve.

Strongly-typed language: Angular uses TypeScript, a strongly-typed language that allows for better code organization, catch errors early on, and provide better tooling support. React, on the other hand, uses JavaScript, which is a dynamically-typed language that can sometimes lead to errors that are difficult to catch.

Consistent coding standards: Angular has a set of coding standards and best practices that help ensure that code is consistent and maintainable, making it easier for developers to work on large codebases. React, on the other hand, is more flexible, which can sometimes lead to inconsistencies in code style and structure.

While React is still a great option for building web applications, Angular’s comprehensive framework, two-way data binding, strongly-typed language, and consistent coding standards give it a slight edge over React in terms of ease of use, maintainability, and scalability.

Ionic 7 framework is here!

Ionic 7 is the latest and greatest version of the popular mobile app development framework. It’s so good, it’ll make you want to put on your favorite coding socks and dance around your computer like nobody’s watching.

But in all seriousness, Ionic 7 offers some fantastic benefits over its older versions. Its improved performance will have your app running like a well-oiled machine, or at least like a machine that’s had a few cups of coffee in the morning. And with the updated design system, your app will look so good it’ll make your users wonder why they ever bothered with other apps in the first place.

And let’s not forget Capacitor 3, the native runtime that allows developers to build cross-platform mobile apps using web technologies. It’s like having a magical wand that can turn your web app into a mobile app with just a few flicks of your wrist.

But upgrading to Ionic 7 isn’t just a walk in the park, it’s more like a marathon. You’ll need to update your dependencies, configuration files, and code. It’s enough to make a developer break out in a cold sweat, or at least reach for the coffee (or energy drink) to power through.

But fear not, intrepid developer! Once you’ve upgraded and tested your app, you can sit back and relax knowing that you’ve done your part to keep up with the latest and greatest in mobile app development. And who knows, maybe your app will become the next big thing and you’ll be able to retire to a tropical island with nothing but your laptop and a good book (or maybe just a good IDE).

So what are you waiting for? Upgrade to Ionic 7 and start building mobile apps that will make your users say “Wow, this app is so great I want to give the developers a hug… or at least a virtual high-five.”

Benefits of Upgrading to Ionic 7

Upgrading your Ionic app to version 7 offers several benefits:

  • Improved Performance: Ionic 7 comes with a faster rendering engine and improved performance optimizations that can significantly improve the speed of your app.
  • Updated Design System: The new version of Ionic features an updated design system that provides a more modern and polished look for your app. It also comes with new UI components that can enhance the user experience of your app.
  • Support for Modern Web Platform Features: Ionic 7 is built on top of the latest web technologies, which means that it comes with support for modern web platform features such as CSS grid, CSS variables, and more.
  • Bug Fixes and Security Improvements: Upgrading to Ionic 7 ensures that your app benefits from the latest bug fixes and security improvements.

To upgrade your Ionic app to version 7, follow these simple steps:

  1. Check Compatibility: Before upgrading, check the Ionic documentation to ensure that your existing app is compatible with version 7.
  2. Update Dependencies: Use the npm-check-updates tool to update your project’s dependencies to the latest version of Ionic.
  3. Update Configuration Files: Update your project’s configuration files, such as package.json and angular.json, to reflect the changes in version 7.
  4. Update Code: Update your app’s code to use the new APIs and components introduced in Ionic 7.
  5. Test Your App: After updating your code, test your app thoroughly to ensure that it works as expected.
  6. Deploy Your App: Once you have updated and tested your app, deploy it to your production environment.

By upgrading your Ionic app to version 7, you can take advantage of these benefits and build high-quality mobile apps using web technologies.

  • Ionic Academy – A comprehensive collection of Ionic tutorials ranging from beginner to advanced levels.
  • Official Ionic Docs – The official documentation for Ionic 6, covering everything from installation to advanced topics.
  • Simon Grimm’s Tutorials – A series of Ionic 6 tutorials by Simon Grimm, covering a range of topics from beginner to advanced.
  • Josh Morony’s Tutorials – A collection of Ionic 6 tutorials by Josh Morony, with a focus on practical examples and real-world use cases.
  • Angular Firebase’s Tutorials – A set of tutorials on building Ionic 6 apps with Firebase integration by Angular Firebase.
  • Javabrains’ Tutorials – A series of video tutorials covering the basics of Ionic 6 by Javabrains.

How to convert div containing an image into a png in Ionic/Angular

You can do this by installing the html2canvas library via `npm i html2canvas`
But you have to remember to useCORS if your div includes an externally located image! very important.


html2canvas(this.screen.nativeElement, {
      useCORS: true, //By passing this option in function Cross origin images will be rendered properly in the downloaded version of the PDF
    }).then(canvas => {
      this.canvas.nativeElement.src = canvas.toDataURL();
      this.downloadLink.nativeElement.href = canvas.toDataURL('image/png');
      this.downloadLink.nativeElement.download = new Date() + '.png';
      this.downloadLink.nativeElement.click();
    });

How to fix ion-checkbox stealing clicks on ion-item elements

How to fix ion-checkbox stealing clicks on ion-item elements.

I found this annoying issue with Ionic 5 where clicking on ion-label inside ion-item can’t be clicked if there is also an ion-checkbox element.

You have to change the z-index on the element you want clickable.

// component css
ion-label{
   z-index: 3;
}

You can also disable button property on ion-item, check the docs here.

You can also apply this to any other element you want to use inside ion-item. Good luck!

Implement App Tracking Transparency for Ionic Angular and Cordova iOS app

How to use the https://github.com/chemerisuk/cordova-plugin-idfa plugin in Ionic v3.

I had some issues using the example provided so I had to call the exec directly:

// first install the plugin
// cordova plugin add cordova-plugin-idfa
// npm i cordova-plugin-idfa --save

// add permissions to config.xml under ios platform
<platform name="ios">
    <edit-config target="NSUserTrackingUsageDescription" file="*-Info.plist" mode="merge">
        <string> My tracking usage description </string>
    </edit-config>
</platform>

// has to be called after platform is ready
// this.platform.ready().then(() => {}

askTrackingPermission() {
    if (this.platform.is('cordova') && this.platform.is('ios')) {

      if (window.cordova) {
        console.log('trying to request permission ');
        window.cordova.exec(win, fail, 'idfa', "requestPermission", []);
      }
    }

    function win(res) {
      console.log('success ' + JSON.stringify(res));
    }
    function fail(res) {
      console.log('fail ' + JSON.stringify(res));
    }
  }

readTrackingPermission() {

    if (this.platform.is('cordova') && this.platform.is('ios')) {

      if (window.cordova) {
        window.cordova.exec(win, fail, 'idfa', "getInfo", []);
      }
    }

    function win(res) {
      console.log('success  ' + JSON.stringify(res));
    }
    function fail(res) {
      console.log('fail ' + JSON.stringify(res));
    }
  }

Also, you can only test this from the iOS simulator (or device) running 14.5.1+ iOS. In your iOS device settings check privacy->tracking (setting) it has to be allowed to ask. And you will only be able to ask the user once.

Good luck!

How to Open PDF/File in Ionic on Android

How to Open PDF/File in Ionic on Android?

If you recently tried to open a file in Ionic from the application dir using `fileOpener2` plugin you may have encountered an error `File Not Found` which could indicate permission error.

It turns out you can’t open a file from `applicationDirectory` directly, you have to copy it into another directory:

if (this.platform.is('android')) {
  const self = this;
  const targetFile = self.file.dataDirectory + '/' + yourFileName;
		
  self.file.copyFile(self.file.applicationDirectory + 'www/assets/', yourFileName, 
                     self.file.dataDirectory, yourFileName).
           then(function (res) {
	     self.fileOpener.open(targetFile, 'application/pdf');
	});
}

Install the Cordova Plugin here:

https://github.com/pwlin/cordova-plugin-file-opener2
https://ionicframework.com/docs/native/file-opener

How To Create Downloadable CSV File in JS/Angular

 
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();
}
      

How Much Access Does Facebook App Have?

These are the permissions Facebook app has on Android devices:

Device & app history:

Retrieve running apps

Storage:

– read the contents of your USB storage
– modify or delete the contents of your USB storage

Location:

– approximate location (network-based)
– precise location (GPS and network-based)

Phone:

– write call log
– read phone status and identity
– read call log
– directly call phone numbers

Microphone:

– record audio

Identity:

– add or remove accounts
– read your own contact card
– find accounts on the device

Wi-Fi connection information

– view Wi-Fi connections

SMS:

– read your text messages (SMS or MMS)

Calendar:

– add or modify calendar events and send email to guests without owners’ knowledge
– read calendar events plus confidential information

Contacts:

– read your contacts
– modify your contacts
– find accounts on the device

Device ID & call information:

– read phone status and identity

Photos/Media/Files:

– read the contents of your USB storage
– modify or delete the contents of your USB storage

Camera:

– take pictures and videos

Other:

download files without notification
receive data from Internet
adjust your wallpaper size
control Near Field Communication
create accounts and set passwords

toggle sync on and off
view network connections
send sticky broadcast
change your audio settings
set wallpaper

reorder running apps
modify system settings
read sync settings
install shortcuts
prevent device from sleeping
connect and disconnect from Wi-Fi

pair with Bluetooth devices
run at startup
read battery statistics
full network access
control vibration

expand/collapse status bar
access Bluetooth settings
draw over other apps
read Google service configuration
change network connectivity

How To Batch commands in .bat file on Windows

Using the && ^ operators we can batch different commands to be executed in windows command prompt.

// example file – test.bat

mkdir newdir && ^
rd /s /q somefolder/otherfolder && ^
rd /s /q difffolder/otherfolder

Using only a single & symbol will make the following command execute even if the current one fails.
Also this is a good example of how to delete folders in a quick efficient way.

Google Android Play Store Target API Requirement Change

From Google:

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" />