Delphi XE4 iOS client notifications [Edit]

We are building an app for iOS and need to be able to listen for asynchronous client-side notification events created by a third party library. It was pretty difficult to figure out how to import the third-party objective C library but we were able to do it by creating "fake calls." We can now compile and run the application but have not been able to register our application to receive notifications created by the third party library. For example, we have a credit card swiper that plugs into the audio jac
k. When a credit card is swiped, it creates an asynchronous client notification and puts it into the notification center via the SDK. The SDK instructs to register notification observer through iOS's NSNotificationCenter. However, I cannot find a function in the delphi library to do this (I can easily create notifications using IFMXNotificationCenter, however, cannot consume notifications from other apps/libraries).

The way we are trying to attach to the client notification is by using calling a function similar to this one in Cocoa:

{cocoa code}
[[NSNotificationCenter defaultCenter] addObserver:self 
                         selector:@selector(downloadDataComplete:) 
                         name:NOTIF_DataComplete object:nil]; 

Where ‘NOTIF_DataComplete’is the Notification Name:
// For name of notification
extern NSString * const NOTIF_DataComplete;
{end cocoa}

The problem I think is trying to determine the equivalent of the 'Cocoa' Self. If we try to pass in self (the delphi xe 4 app) as is we get an access violation. So we added a property to our application of type tOCLocal so that the iOS library can get the object id of our application as a reference (this idea came from how one of the delphi xe4 translated units that handles keyboard client notification events) and feed notifications to it. The code compiles, however, if any code is in the callBackFunction
 then we get an access violation. 

The delphi code is below.

{code}
TNSNotificationCenter.Wrap(TNSNotificationCenter.OCClass.defaultCenter).
    addObserver(FCVNotificationHandler.GetObjectID, sel_getUid(callBackFunction:'),  (NSSTR('NotificationName') as ILocalObject).GetObjectID, nil);
{code}

I've checked just about everywhere and cannot find anything on how to have XE4 handle local client notifications. If you can help it would be greatly appreciated.

Thanks.

Edited by: Charles Vinal on Jun 24, 2013 11:33 AM

Edited by: Charles Vinal on Jun 24, 2013 11:50 AM
0
Charles
6/24/2013 6:56:24 PM
embarcadero.delphi.ios 412 articles. 0 followers. Follow

8 Replies
1575 Views

Similar Articles

[PageSpeed] 34

After additional research I think this question can be narrowed down to:

How do you pass the equivalent of "self" (being your iOS firemonkey application) to the iOS notification center?

e.g., 

[[NSNotificationCenter defaultCenter] addObserver:*self* 
selector:@selector(downloadDataComplete:) 
name:NOTIF_DataComplete object:nil]; 

if you actually pass in "self" you get an access violation.
0
Charles
6/24/2013 8:08:46 PM
> if you actually pass in "self" you get an access violation.

It needs to be a pointer to an Objective-C object. To create one in Delphi, you need to derive a class from TOCLocal, and have it implement one or more interfaces with the methods you want to expose as Objective-C methods. For examples, you can check out the FMX source; I also blogged a few during the XE2 release cycle (http://delphihaven.wordpress.com/?s=TOCLocal).
0
Chris
6/24/2013 8:37:45 PM
Am 24.06.2013 22:08, schrieb Charles Vinal:
> After additional research I think this question can be narrowed down to:

Hello,

after initial research this question belongs into the following group
where you'll get more and better answers:

embarcadero.public.delphi.plattformspecific.ios

NNTP followup for newsreaders set accordingly so all answers via
newsreader will go directly to this location.

Greetings

Markus
0
Markus
6/24/2013 9:16:23 PM
> NNTP followup for newsreaders set accordingly so all answers via
> newsreader will go directly to this location.

How about moving the whole thread instead, given I've provided an answer already...
0
Chris
6/24/2013 9:35:16 PM
> {quote:title=Chris Rolliston wrote:}{quote}
> > if you actually pass in "self" you get an access violation.
> 
> It needs to be a pointer to an Objective-C object. To create one in Delphi, you need to derive a class from TOCLocal, and have it implement one or more interfaces with the methods you want to expose as Objective-C methods. For examples, you can check out the FMX source; I also blogged a few during the XE2 release cycle (http://delphihaven.wordpress.com/?s=TOCLocal).

Thanks Chris. Prior to posting I created a property on the form (FCVNotificationHandler) that was decended from tOCLocal and passed it in this way:
TNSNotificationCenter.Wrap(TNSNotificationCenter.OCClass.defaultCenter).
    addObserver(*FCVNotificationHandler.GetObjectID*, sel_getUid(callBackFunction:'),  (NSSTR('NotificationName') as ILocalObject).GetObjectID, nil);

If I create it as an object, what should the scope be?
0
Charles
6/24/2013 9:44:46 PM
I agree - it would be good to move it to the iOS forum. Right after I posted i found that forum but I didn't want to double-post.
0
Charles
6/24/2013 10:27:23 PM
The passing of the tOCLocal object decendant may be working (we don't get a AV on initial run). However, when the notification event occurs, we get an access violation IF we put code in the event handler (if no code, then no access violation). I saw posts from mid-may that discussed a similar issue when receiving remote notifications - problem had to do with the applicationDidReceiveRemoteNotification delegate having the same signature as the applicationDidFinishLoadingWithOptions.We are trying to see if 
there is a similar issue with local notifications.
0
Charles
6/24/2013 10:35:13 PM
> The passing of the tOCLocal object decendant may be working (we don't get a AV on
> initial run). However, when the notification event occurs, we get an access violation

You've got to be careful because there are two reference counts, one for the part of the object implemented in Objective-C and one for the part implemented in Delphi (confusing, eh?). Do you have a compilable sample that exhibits this behaviour?

> IF we put code in the event handler (if no code, then no access violation).

I may be wrong, but that sounds like the object has already been freed (or should I say, disposed of) by the time the method is called by the Apple API. Perhaps override Destroy and stick a breakpoint in it to see...?

> problem had to do with the applicationDidReceiveRemoteNotification delegate
> having the same signature as the applicationDidFinishLoadingWithOptions

Hmm, I don't see how that would have anything to do with causing an AV. Objective-C distinguishes methods by parameter name, Object Pascal by parameter type; as such, you may need to distiguish the types, as you yourself suggest near the top of that May thread.
0
Chris
6/24/2013 10:54:50 PM
Reply:

Similar Artilces:

MOVED: Delphi XE4 iOS client notifications [Edit]
Moved on request to embarcadero.public.delphi.platformspecific.ios or: https://forums.embarcadero.com/thread.jspa?threadID=88951 -- Rudy Velthuis (TeamB) http://www.teamb.com "Once you have seen certain things, you can't un-see them, and seeing nothing is as political an act as seeing something." -- Arundhati Roy ...

why delphi xe4 does not have a demo for IOS Rest DataSanp Client ? [Edit]
I really need Demo for Res DataSnap Server (connect to mySql /msSql) and a IOS Rest DataSanp Client. But I can't not find any? Why? Mainly, I need to know how to add, delete, update records on IOS Rest DataSanp Client. Anyone could provide a hint.!!! Mitchell Hu Edited by: Mitchell Hu on May 24, 2013 12:17 PM Edited by: Mitchell Hu on May 24, 2013 12:22 PM ...

I can to install one not delphi program foir iOS into one iOS for delphi?
For example i have one programm builded as xcode for iOS, and i build one program as delphi for iOS. I want to have only one instalation, i can to add this xcode program into my delphi installer of my ios program? I can to do the same as android? how i can to to this? > {quote:title=oscar mejia wrote:}{quote} > For example i have one programm builded as xcode for iOS, and i build one program as delphi for iOS. I want to have only one instalation, i can to add this xcode program into my delphi installer of my ios program? > > I can to do the same as android? how i can to to...

Can I do this with iOS apps developed in Delphi XE4 Pro + iOS?
I still don't have XE4/iOS as I have some questions first. Do I have access to iOS "native" library/system? What do I use for internet (downloading files etc.) - Indy? *If my research is correct, Google maps is available for iOS? Can I use Google maps or Apple's maps solutions in Delphi iOS apps?* If I have XE4 Pro, can I still use database functionality? Any restrictions? (Am I allowed to use what iOS offers or connect with a database on a webserver?) Anyone here developed demo apps I can see available in Apple iTunes store? (Even simple apps is okay as I onl...

How do I remove IOS from the Delphi XE4 compile? [Edit]
I have mistakenly turned on IOS compile for a project. How do I turn off IOS Delphi XE4 compile attempts? Compiling DocGen.dproj (Debug, Win32) dcc command line for "DocGen.dpr" Success Elapsed time: 00:00:01.2 Deploy paclient command line for "WS210" [PAClient Error] Error: E0003 Connection to 'WS210' on port 64211 failed [PAClient Error] Error: E0003 Please make sure that 'Platform Assistant Server' is running on the host machine and is configured to use port 64211 Failed ============================ Looks like it will compile for Windows. I c...

Delphi XE4 - Firemonkey
I have an application that runs fine on windows, however when running on iOS simulator the onKeyUp event for a TEdit control is not being fired? Please advise if this event should get fired when running on iOS? This problem occurs onKeyUp events created directly on the control and by assigning the event programatically. Running XE4 update 1 iPhoneOS6.1.sdk Minimac: OS X 10.9 XCode 5 iOS Simulator Version 7.0 - iPad Retina / iOS 7.0.3(11B508) ...

Implementing a sip client on delphi xe4 firemonkey for iOS
:-) I need to develop a voice and video SIPclient for iOS using XE4 Firemonkey. What the best way to do this? It´s SIP supported by Firemonkey? Are there any APIs? Regards Gustavo wrote: > I need to develop a voice and video SIPclient for iOS using > XE4 Firemonkey. What the best way to do this? Good luck. SIP is not a trivial protocol to implement manually. You are best off finding a pre-made SIP library to do the work for you. > It´s SIP supported by Firemonkey? I seriously doubt it. > Are there any APIs? SIP is an application-layer proto...

Delphi XE4,XE5 100% Native iOS Components [Edit]
Delphi XE4,XE5 100% Native iOS Components http://sourceforge.net/projects/dpfdelphiios/ > {quote:title=Babak Yaghoobi wrote:}{quote} > Delphi XE4 100% Native iOS Components > > http://sourceforge.net/projects/dpfdelphiios/ Great work! Thanks for sharing this with us! > {quote:title=Babak Yaghoobi wrote:}{quote} > Delphi XE4,XE5 100% Native iOS Components > > http://sourceforge.net/projects/dpfdelphiios/ If only Embarcadero would include native components as well. I'd love a supported release as opposed to a community release that may simply e...

App works in IOS simulator with Delphi XE4 and fails after Update 1 install [Edit]
Hi! When I install update 1 and installing new update 1 PAserver and run my application (very simple Firemonkey Mobile Application) I get: "Project xxx raised exception class SIGSEGV (11)". When I reinstall Delphi XE (without update 1) everything works fine again, I have tried to remove all code in FormCreate and OnActivate without luck. What can this be? I have also tried with the old PAserver but this doesnt work either. It Works when running to physical devices like Iphone4 and Ipad mini. But when I select to run from the simulator this errormessage comes back ag...

Reviews of Delphi XE4 / iOS?
I would like to see some comprehensive reviews on XE4 iOS before making a decision... Also questions like if it will be possible to e.g. use 3rd party libraries like Google maps for iOS when using Delphi FireMonkey https://developers.google.com/maps/documentation/ios/start Am 24.05.2013 01:41, schrieb Thomas Schulz: > I would like to see some comprehensive reviews on XE4 iOS before making a decision... > > Also questions like if it will be possible to e.g. use 3rd party > libraries like Google maps for iOS when using Delphi FireMonkey > > https://developers...

Delphi ios Push Notifications
I've been looking at the following document: http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 And wondered whether someone did a iOS notification Client/Server in XE2? --- Amit Following my other question.... How can I translate and incooperate the following objective-c code, as fpc objective-pascal? Using the iOS Delphi platform? I got this objective-c code: " ----------------------- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //self.window.rootViewControl...

Does Delphi for iOS come with native iOS UI controls?
According to this link http://www.embarcadero.com/products/delphi/ios-development, Delphi for iOS comes with "Pixel-perfect native UI controls". Are those controls the iOS native ones (UILabel, UIText, UISwitch, MKMapView, etc.), i.e. the same ones that one sees in XCode InterfaceBuilder? Le 31/01/13 19:02, Jacques Gonzalez a écrit : > According to this link http://www.embarcadero.com/products/delphi/ios-development, > Delphi for iOS comes with "Pixel-perfect native UI controls". > > Are those controls the iOS native ones (UILabel, UIText, UIS...

My first iOS app with Delphi XE4
Hello I just made a video from my first iOS app that I made with Delphi XE4: http://www.youtube.com/watch?v=u_lEPpp7oeA This is a software that "turns" your iPhone into a security camera, streaming live video from the iPhone camera to Digifort camera surveillance system (Also compiled in XE4). I took about 2 weeks to finish the app (Including the time to learn the Firemonkey for iOS), but now I'm just waiting apple developer to be online again in order to send my app for approval Comments are appreciated! Eric Fleming Bonilha wrote: > Comments are appreciated...

iOS System Info (Delphi XE4)
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --JivePart=_8c7a0.zeB8CwDOH5aMJzMl Content-Type: text/plain; charset="Utf-8" As per the "Detecting if iPhone 5" thread in delphi.firemonkey group, or for anyone else interested. Remember to fill out the provisioning info in the project options if you're going to test/deploy to your device. -- Dave Nottage [TeamB] --JivePart=_8c7a0.zeB8CwDOH5aMJzMl Content-Type: application/octet-stream; name="iOSSystemInfo.zip...

Web resources about - Delphi XE4 iOS client notifications [Edit] - embarcadero.delphi.ios

Notification Center - Wikipedia, the free encyclopedia
iOS 7.1.1 / April 22, 2014 ; 4 months ago ( 2014-04-22 ) that provides an overview of alerts from applications. It displays notifications until ...

Facebook Testing Mobile Notifications Promoting Hashtags, Trending Topics?
Following last week’s discovery that Facebook was testing a trending topics module in the upper-right-hand corner of its desktop News Feed in ...

Smartphone email notifications 'a toxic source of stress', psychologists say
The secret to happiness is to turn off notifications from your smartphone email app, according to a new study.

My top 2015 essays on Uber, online dating, push notifications, Apple Watch, and more
... this out: In the meantime, below are a list of my top essays from 2015. It includes writing on a bunch of topics: Uber, Dating apps, Push notifications ...

Incipio debuts ClamCase keyboards for iPad Pro, mini 4 + Air 2, adds power, notifications
... three for the iPad Air 2, and one for the iPad mini 4. Some of the keyboards feature premium features such as an integrated screen for notifications, ...

Pinterest Adds Price Drop Notifications to Buyable Pins; Hits 1 Million Biz Milestone
Pinterest today announced a new feature for Buyable Pins : the ability to send price drop notifications. The company this week also celebrated ...

Launcher with Notification Center Widget adds more magic
If you regularly use Launcher with Notification Center Widget to perform actions with a tap, then an update today, Jan. 20, giving you more options ...

Contextual and Granular Notification Controls
I love getting notifications on my phone. I’ve written a lot about notifications, at one point calling the notifications screen “my home screen.” ...

How Twitter used Doze in Android 6.0 Marshmallow to Improve Notification Performance
... Android M we have a greater ability to be good citizens when it comes to conserving battery life. This feature lets us specify which notifications ...

How to send app crash reports to OS X Notification Center
OS X is about as reliable as any operating system out there, but apps still can – and do – crash. When they do, they take up the entire middle ...

Resources last updated: 1/20/2016 8:29:04 PM