Category Archives: Apple

Delphi iOS Client Push Notification setup

Apple APNs iOS Client with Delphi 10.3+~

Prolog: A Lot is written how to implement APNs in various languages. I didn’t find, though proper one stop to learn how to implement APNs via IDERA’s Delphi. Basically, a main task with this procedure is with dealing with Apple Certifications (which is widely documented over many guides and sites).

Eventually you’d have to forge these files:

  • CertificateSigningRequest.certSigningRequest – to request a certification from Apple Services
  • Go to in Apple Developer Certification Web Console – to the AppID Identifier, and the Push Notification Capability – use the .csr to request a – And download .cer file.

    • Development SSL Certificate or
    • Production SSL Certificate
  • Use the aps_production_cert.cer – The Certification which needs to be installed in your Mac OS
    • clicking the ‘.cer’ file will add it to ‘My Certifications’ under the ‘Keys Chain’ – (Important this should appear on the ‘My Certifications’ if it isn’t there file won’t be able to get exported as a .p12)
  • Certificates.p12 – exporting the Push Certification as ‘.p12’
  • Certificates.pem – convert the ‘.p12’ file to ‘.pem’ file using openssl command:
    • openssl pkcs12 -in Certificates.p12 -out Certificates.pem -nodes
  • entrust_root_certification_authority.pem – The Apple CA (it can be downloaded from
  • To test that I used the .php object (basically you can code a server using Delphi as well… but I tested that with this .php server object) from

We are using in Delphi the TMessageManager.DefaultManager class to register for various messages from the iOS APN service. Such as when registration and receiving from the system the Device TokenID. Or when this procedure fails.. http://docwiki.embarcadero.com/Libraries/Sydney/en/System.Messaging.TMessageManager.SubscribeToMessage

And using the TiosHelper.SharedApplication to obtain the UIApplication and register the client iOS device for notifications using registerUserNotificationSettings(..); and registerForRemoteNotifications(); These procedures respond with a MessageData containing the unique device token.

uses
  // :
  FMX.Platform.iOS, System.Messaging, FMX.Platform,
  iosapi.Helpers, iOSapi.Foundation, FMX.Helpers.iOS, iOSapi.UIKit;

procedure TForm2.LogMsg(Value: String);
begin
  edtLog.Lines.Add(Value);
end;

procedure TForm2.RegisterNotificationClick(Sender: TObject);
var
  types: UIUserNotificationSettings;
begin
  // The token obtained from the TPushDeviceTokenMessage event should be used to identify the iOS client and send notifications to it
  TMessageManager.DefaultManager.SubscribeToMessage(
    TPushDeviceTokenMessage,  procedure(const Sender: TObject; const M: TMessage)
      begin LogMsg('TPushDeviceTokenMessage: ' + (M as TMessage<tpushdevicetokendata>).Value.Token); end);

  TMessageManager.DefaultManager.SubscribeToMessage(
    TPushFailToRegisterMessage, procedure(const Sender: TObject; const M: TMessage)
      begin LogMsg('TPushFailToRegisterMessage: ' + (M as TMessage<tpushfailtoregisterdata>).Value.ErrorMessage); end);

  TMessageManager.DefaultManager.SubscribeToMessage(
    TPushRemoteNotificationMessage, procedure(const Sender: TObject; const M: TMessage)
      begin LogMsg('TPushRemoteNotificationMessage: ' + (M as TMessage<tpushnotificationdata>).Value.Notification); end);

  TMessageManager.DefaultManager.SubscribeToMessage(
    TPushStartupNotificationMessage, procedure(const Sender: TObject; const M: TMessage)
      begin LogMsg('TPushStartupNotificationMessage: ' + (M as TMessage<tpushnotificationdata>).Value.Notification); end);

  types := TUIUserNotificationSettings.Wrap(TUIUserNotificationSettings.OCClass.settingsForTypes(
    UIUserNotificationTypeBadge or UIUserNotificationTypeSound or UIUserNotificationTypeAlert, nil));

  TiosHelper.SharedApplication.registerUserNotificationSettings(types);

  TiosHelper.SharedApplication.registerForRemoteNotifications();

  LogMsg('TiOSHelper.SharedApplication.registerForRemoteNotifications;');
end;

Technition input on a simple install that went sour

Today I spent almost all day trying to figure out how to install the iTunes on a stubborn windows machine that would not install properly the Apple (loaded) ITunes.

To make a long story short, I came up with the following:

  • Concerning ITunes, (or any other applications that might change the initial state of the machine, with putting values into registry or registering drivers, of one kind or another) make sure you create a system restore point before making any changes to the system. This will enable you to always restore the system — to a state where everything was “clean” before any of installations you are about to preform.
  • The current Apple ITunes has a problem, where it doesn’t register (perfectly on all systems) the IPod/IPad/IPhone… I had to digg into the web in order to see all the comments from other users, where they complained about the same issue. Some of the complains resulted with good ideas of how to solve the issue. Yet, none of them helped on my case.
  • Apple Packed the Current ITunes installation with a variety of different software packages — each has its own roll… Yet, When an error occurs, sometimes, it would be best to separate this big ITunes package into its components — and install only the required component when needed. Below is the list of the current components in ITunes.
  1. AppleApplicationSupport.msi
  2. AppleMobileDeviceSupport64.msi – The drivers and software components that does the connection between ITunes and your devices.
  3. AppleSoftwareUpdate.msi
  4. Bonjour64.msi
  5. iTunes64.msi – The Main ITunes Application

BTW: I’ve separated the file iTunes64Setup.exe using the excellent WinRAR from RAR Labs.

On my case I had to run a couple of times the AppleMobileDeviceSupport64.msi in order to install the drivers (due to the fact that they were registered properly).

BTW:
You can extract each .msi install file, using the following command:
msiexec /a {filename} TARGETDIR=c:\theinstalldirectorysource

  • On today’s tries when installing ITunes — I learned that whenever a major application is being installed faulty — It would be best to enter the windows safemode. And install the software on a  trusted environment (without interference or antiviruses or firewalls definitions).

 

Podcasts RSS: Aggregating Video/Audio/Podcasts

I thought for a couple of days what to write about, due to the fact that nothing much kept me busy… Though, I came to a conclusion that I’ll write about what did keep me going on all these days.

For the past dozen years, I’ve been hearing many different daily Podcasts…

So what is a Podcast?

A Podcast, is basically a media file (can be audio or video) which is being attached to a RSS (Really Simple Syndication). The RSS with the combination of the media file, makes it a very power full technology. That because different Feeds are being updated daily or weekly.

The programs that manage the different feeds (Podcasts Apps; such as Apple Podcasts app [on iOS] or Samsung KiesCast app [on android]), you listen to — know 🙂 but their definition whether it is a new item, or an old one… Thus notify you for the new ones.

History of RSS…

The RSS first was invented for Text news… News Feeds, were common, yet, attaching a video/audio file to it was a latter invention.

More about Audio Podcasts:

There are some more features which were added to the Feed,. and can be supply attached to the RSS Feed it self, or to the media file which attached to it.

Meta Tags:

Take for example the Meta Tags.

When adding an item for a feed, it includes a text which describe the current item (of course these additions should be supplied in such a way that the miscellaneous Podcasts apps aggregators would know where to look for that data).  Due to the fact the the RSS was derived from XML (Extensible Markup Language) files — which is a structured text file, with different variables with in it — It can contain many different Meta Tags.

In addition misc meta tags can be attached to the media file itself. For example a .mp3/.m4a audio files contain a structure that define the file meta tags. And their meta tags can include many different known, or user defined tags. Such as; Track Name, Year Published, Author, Lyrics, Picture Thumbnail — Icon of the track, and so on.

Different Sources of RSS Podcasts:

Today any news organization which respect itself got a team that compile a hourly/daily/weekly podcast. After all, all you need to create a podcast — it the knowledge how to construct the basic feed, and some hardware such as microphone and a recording application… And of course some content to talk about whether it’ll be global news/ Tech news/ Expert news/ Art news/ or any area which interest you.

My personal daily news:

I’ve been listening, as I mentioned, for the past dozen years to news via different podcasts apps, and being fed news from different sources. This of course is a routine change from the past — instead of  gazing on a TV screen — I am now free, to hear news — what ever — when even — and where ever — I like.

What Ever; Pick from the billion of podcasts sources online.

Where ever; I can hear news while doing the daily arrangements around the house — when doing the dishes, or any other tasks.

When Ever; Feeds by different sources are usually kept at least for a week and on many cases for years back on different sources. So even if I missed something, or if I would like to listen to new content to me — I can search it years back on the source WebSite.

Or for short the podcasts WWW 🙂

APNS – Apple Push Notification Server

I’ve updated my code on the iOS client of the “Apple Push Notification Server”. With its companion the Server side. This version of code was written in Delphi, for windows desktop environment — and I’ve enhanced it a bit. Had to understand the thingies with the signing and all the procedure.
If you are in the progress of building one yourself here are my notes on the subject:

  • Make sure you are consistent with the type of app you are developing. Basically there are two kinds: Development & Production (Distribution). What ever you choose note the following assignments:
  1. Code sign your APNS with the proper type (DEV/PRO)
  2. Assign the server to be connected to the proper gateway:
    A. gateway.sandbox.push.apple.com:2195 – for DEV
    B. gateway.push.apple.com:2195 – for PRO
  3. Make sure your type is consistent to the client side (DEV/PRO) – The type of kind will produce a different value for the client APN Token when registration the client on the server side.

I’ve created a NotificationPanel for my windows desktop machine. Yet, it isn’t as fancy as the Apple/Google ones. But it inform me on different messages that I’ve connected it to. I’ve registered it as a COM AutomationObject, so it could be used in Microsoft VBA scripts, or similar applications.

One of the features of that code is the ability to send a message via my APNS registered server.

I am still trying to figure out, why not all of the messages being sent via the APNS reach the client side. I do not know where it actually fails [Client or Server side].

In addition there is the issue with the APNS feedback system (feedback.push.apple.com:2196) which I didn’t manage to verify its function. My version of code, for it, doesn’t seems to receive and feedbacks — whether messages has been sent properly or not, and if not — what is the exact reason.