Creating a Simple Safari Extension

Previously, I developed a Chrome extension that converts URLs into QR codes and wanted to use a similar extension in Safari. After searching, it seemed there wasn’t one available, so I decided to create a Safari extension myself and document the process. Obtaining a Developer Certificate To create a Safari extension, you first need to generate a developer certificate. Visit the Apple Developer Center and join the Safari Developer Program, which is free. Once you’re part of the developer program, you can generate a certificate by visiting Certificates, Identifiers & Profiles, clicking the plus sign in the top right corner, and generating a developer certificate. After successfully creating it, download the certificate to your local machine and import it into Keychain Access. ...

October 23, 2014 · 4 min · Zhiya

Exploring Push Notification Registration Failures in iOS8

Apple officially released iOS8 on September 18th. Upon updating, I discovered that my app could not launch on iOS8. The Console displayed the following message: 2014-09-19 16:26:20.369 demo[379:30506] registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later. Upon checking the documentation, I found that the method registerForRemoteNotificationTypes used for registering push notifications has been deprecated in iOS8. The documentation states: Following the documentation’s guidance, I replaced it with the registerForRemoteNotifications method, which does not accept any parameters. However, this led to a new issue: the app could successfully register on devices where it was already installed, but failed to register on newly installed iOS8 devices. Neither application:didRegisterForRemoteNotificationsWithDeviceToken: nor application:didFailToRegisterForRemoteNotificationsWithError: responded, and on devices where registration was successful, push notifications were received without sound alerts. Further review of the documentation revealed the following: ...

September 19, 2014 · 2 min · Zhiya

Differences Between Air SDK and Flex SDK

Recently, I upgraded the SDK for AS development from Flex SDK 4.9.1 to Air SDK 4.0, which caused a previously written FLV player to stop playing videos. Eventually, I discovered the bug was due to a variable name in a method being the same as a get method in the class. The situation is similar to what is shown in the image below: In the image, the variable time and the get method time have the same name. The compiler handles this naming conflict differently in Flex SDK and Air SDK. ...

March 27, 2014 · 1 min · Zhiya

Installing Flash Builder Plugin in Eclipse 4.3

Flash Builder is an Eclipse-based IDE. In the utilities directory of the Flash Builder folder, Adobe has provided an installation program for the plugin version, named Adobe Flash Builder 4.7 Plug-in Utility. This plugin version allows you to integrate Flash Builder into an already installed Eclipse as a view, enabling you to develop AS programs within Eclipse. After running the plugin installation program and following the prompts, you will find that the current latest version of Eclipse is 4.3. However, the Flash Builder 4.7 plugin version only supports Eclipse 3.7 or 4.2 and cannot be installed on 4.3. ...

February 27, 2014 · 1 min · Zhiya

Object Keys in Javascript

Let’s take a look at a piece of code: <div id="e1"></div> <div id="e2"></div> <script> var c1 = document.getElementById("e1"); var c2 = document.getElementById("e2"); var obj = {}; obj[c1] = 1; obj[c2] = 2; console.log(obj); </script> What will this code output? The answer is: Object {[object HTMLDivElement]: 2} Why does it output only one element when we assigned two elements to obj? Could it be that c1 and c2 point to the same element? First, c1 and c2 are two different DOM nodes, and by outputting c1 === c2, you’ll find the result is false. However, the result of obj[c1] === obj[c2] is true. From the above results, we can initially deduce that when c1 and c2 are used as object keys, their values might be the same. An object’s key can only be a string, so when the DOM element c1 is used as a key, it is converted to a string. Since both c1 and c2 are div elements, they are converted to the same string value, and c2 as a key will overwrite c1. This results in only one element being present. If c2 is changed to a different type of DOM node, it will be converted to a different string value. For example, if c2 is changed to a ul, using the same JavaScript code, the output will be: ...

January 8, 2014 · 2 min · Zhiya