Tuesday, October 23, 2018

Ionic 4 + Capacitor + Firebase Messaging + iOS Proof of Concept


How to get Firebase FCM device token from iOS device in an Ionic 4.beta and Capacitor 1.0.0-beta.8 project.


Capacitor push notifications on an Android device returns an FCM device token. However, iOS devices return an APNS device token. Firebase is unable to send a message with an APNS token. However, the APNS token could be used to send a message via Apple's Push Notification Service.

To get an FCM on an iOS device, follow the instructions here for setting up a Firebase Cloud Message Client App on iOS: https://firebase.google.com/docs/cloud-messaging/ios/client

Proof of Concept (in short):

a. Add Firebase pods to /ios/App/Podfile

target 'App' do
  # Add your Pods here
  pod 'Firebase/Core'
  pod 'Firebase/Messaging'

b. Run in the console in /ios/App: pod install

c. In /ios/App/App/AppDelegate.swift insert the following:

// part 1 of 3

import UserNotifications
import Firebase

// part 2 of 3

// Override point for customization after application launch.
    // Use Firebase library to configure APIs
    Messaging.messaging().delegate = self
    if #available(iOS 10.0, *) {
        // For iOS 10 display notification (sent via APNS)
        UNUserNotificationCenter.current().delegate = self
        let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
            options: authOptions,
            completionHandler: {_, _ in })
    } else {
        let settings: UIUserNotificationSettings =
            UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)

// part 3 of 3
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
        print("Firebase registration token: \(fcmToken)")
        let dataDict:[String: String] = ["token": fcmToken]
        NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
        // TODO: If necessary send token to application server.
        // Note: This callback is fired at each app startup and whenever a new token is generated.

Friday, October 12, 2018

Angular 6 Component Require JSON ExpressionChangedAfterItHasBeenCheckedError


In an Angular 6 project, a simple component that gets json data from a local file generates error: ExpressionChangedAfterItHasBeenCheckedError


Do not use the following method to import local json data into the component:
const data = require('./data.json');

Use other standard approaches e.g.

this.http.get(this.dataUrl).subscribe((data: any) => {
    // Do something with json data!

Saturday, August 11, 2018

Ionic 4 Debug With Chrome Sources

In Ionic 3, it was easy to find source .ts code in Chrome's developer tools "Sources" tab for debugging. In Ionic4, it's difficult to find.

In Chrome developer tools "Sources" tab drill into:
webpack:// > . > src > app

Ionic 4 + Capacitor Calling Local API Blocked Mixed Content Error

Ionic 4 + Capacitor app running locally on device. NodeJS + Express + MongoDB API running local on http (not https).

Can hit local API successfully when running Ionic in browser on API url localhost or IPv4 address (e.g.

When running on device (connected via USB) get the following error on all API calls (in Chrome developer tools network tab): (blocked-mixed-content)

Add: "allowMixedContent": true
To: \capacitor.config.json

Tuesday, April 24, 2018

Windows 10 Boot Failure Error Code 0xc000000e

Windows tries to load but fails with blue screen.

Your PC/Device needs to be repaired
The application or operating system couldn’t be loaded because a required file is missing or contains errors.
File: \Windows\system32\winload.exe
Error Code:0xc000000e


I was unable to recover from this error! But Peter was able to -- highly recommended -- he knows his stuff: http://www.peterspcrepair.com/

Notes based on my limited understanding of the problem:

This was one of the clearest articles I could find.
However, my understanding is it's not a suitable fix for a UEFI SSD system drive.

This was one of the clearest articles I could find suitable for UEFI.

My results from command prompt: list vol

What tripped me up is I kept thinking the UEFI volume was the same as the system drive. I could assign a letter and see the files on my system drive (i.e. my C:\ drive with windows). But this is the wrong drive to use for bcdboot. The UEFI is apparently always FAT32. I "think" I should have been using volume 5. Volume 7 seems to be from my Windows 10 recovery disk.

So I should have been running (from command prompt) this:
sel disk 0
list vol
sel vol 5
assign letter=G: Note: G is a unique drive letter not already in use.

Restoring from a recent restore point did NOT resolve the issue. But was done before the boot repair above.

BIOS boot mode changed from "Dual" to "UEFI". Unclear if this was a necessary fix. My understanding is this was NOT necessary. PC had been working with zero issues for the past 3 months.

Friday, January 19, 2018

SuperMicro Desktop Workstation Build 2018

Personal SuperMicro Desktop Workstation Build 2018


  • Happy with price/value/performance.
  • A key requirement was a motherboard with at least one Thunderbolt 3 port.
  • SuperMicro chasis made building the PC very simple and worth every cent. Not visually appealing but not ugly. Fairly quiet.
  • CPU is hitting 100% for minutes with WAMP / Magento 2. In hindsight, would choose a motherboard that supports Xeon E5 which would have allowed for a CPU with more than 4 cores.
  • Broke the first motherboard unplugging the monster GPU. Additional cost to junk/replace.
  • BIOS bootup time seems long. ~15 secs.
  • Chasis front panel plug to motherboard not keyed. Easy to plug in the wrong way. Cable is short, so harder to plugin correct way.
  • More USB ports on the back needed.

SuperMicro Support Q&A

Question: How do I install Windows 10 to the blank system SSD from USB.

Answer: OS must be installed with UEFI mode for M.2 SSD. See youtube link as a reference. 

Question: What is the correct boot order to boot of the SSD system drive.

Answer: Change “UEFI Hard Disk: Windows Boot manager” to boot order #1.

Question: BIOS boot time is slow ~15 secs. How can I improve the speed.

Answer: BIOS needs to detect all the devices inside the system before booting to OS. You can try to disable all the PCIe slots option rom inside the BIOS and disable all the unnecessary features inside the BIOS like serial port.

Question: GPU covers the SSD M.2 port and is awkward to get it in and out. Can I use another port as it would make it easier to install and I’d have direct access to the SSD (if needed).

Answer: you can use slot #2 for your GPU if you don’t have any PCIe card on slot #4. If you have PCIe cards on both slot #2 & #4, then both slots will run as x8.

Components Checklist

  • Motherboard
  • CPU
  • CPU Heatsink
  • CPU Thermal Paste (just in case)
  • RAM
  • GPU
  • Chasis
  • SSD (system)
  • HDD (data)
  • SSD (portable/external)


Supermicro Motherboard ATX for up to Xeon E3-1200v5
SuperMicro X11SAT (-F IPMI support was out of stock)

Intel Xeon E3-1275 v6 Kaby Lake 3.8 GHz 4 x 256KB L2 Cache 8MB L3 Cache LGA 1151 73W BX80677E31275V6 Server Processor

Interesting article on why to choose Xeon:

CPU Heatsink
Supermicro 2U Active CPU Heat Sink Socket LGA1150/1155 (SNK-P0046A4)

CPU Thermal Paste
Arctic Silver 5 High-Density Polysynthetic Silver Thermal Compound AS5-3.5G
*Didn't need because heatsink came with grease. Buy just in case heatsink needs to be removed.

Supermicro 16GB 288-Pin DDR4 2400 (PC4 19200) Server Memory (MEM-DR416L-SL01-EU24)
4 x $206 = $824

Nvidia GTX 1070 Ti
*Nvidia GTX 1080 Ti (preferred but out of stock globally).

865 Watts
SUPERMICRO CSE-743TQ-865B-SQ Black Pedestal Server Case 865W 2 External 5.25" Drive Bays

Power watts/calculator:

SSD System 1TB
SAMSUNG 960 PRO M.2 1TB NVMe PCI-Express 3.0 x4 Internal Solid State Drive (SSD) MZ-V6P1T0BW
HDD Data
WD Black 2TB Performance Desktop Hard Disk Drive - 7200 RPM SATA 2Gb/s 64MB Cache 3.5 Inch - WD2003FZEX

HDD Backup
WD Blue 6TB Desktop Hard Disk Drive - 5400 RPM SATA 6Gb/s 64MB Cache 3.5 Inch - WD60EZRZ

External SSD
Samsung Portable SSD T5 540 MB/s
*Temporary until a good/reliable/portable Thunderbolt 3 external drive available.