Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: Anyone get iOS and Firecloud Messaging working?



Permlink Replies: 47 - Last Post: Apr 18, 2017 1:53 PM Last Post By: Dave Nottage Threads: [ Previous | Next ]
steven chesser

Posts: 395
Registered: 4/13/09
Anyone get iOS and Firecloud Messaging working?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 30, 2017 10:50 AM
Berlin update 2 ...

Well after much issues.... FINALLY got my Token working in iOS ... Thanks to Dave Nottage ....
Our person who handles the provision profiles and all that, had to end up creating me all new ones.
Once that was done... it finally worked! Whew ....

Anyways .....

XCode shows spaces in the token.

Delphi does not show spaces in the token.

Not sure this is an issue yet.

BUT now I am to my next road block....

Using this token with FCM?

I made a FCM app entry for iOS .. filled in the details like I did with the working Android flavor.

But it looks like for iOS side of things... I may need to bounce some things around between the device and FCM to link
them up? And maybe get a FCM token based on my iOS Device token?

FMC incldues demos for C and such.. and some lib files... but after that... not sure what I should be doing with the iOS token now.

I had used this @ http://thundaxsoftware.blogspot.com/2017/01/firebase-cloud-messaging-with-delphi.html

To get Android working but no examples of iOS usage :(

Edited by: steven chesser on Mar 30, 2017 10:50 AM

loki loki

Posts: 710
Registered: 7/1/02
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 30, 2017 12:15 PM   in response to: steven chesser in response to: steven chesser
i m interested too in this :)
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 30, 2017 1:37 PM   in response to: loki loki in response to: loki loki
loki loki wrote:
i m interested too in this :)

https://developers.google.com/cloud-messaging/ios/client#obtain_a_registration_token

This is pretty much where I am stuck at.
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 30, 2017 2:16 PM   in response to: steven chesser in response to: steven chesser
Got my .p12 file uploaded to Firebase ... forgot that part.

Now I can do a POST to

https://iid.googleapis.com/iid/v1:batchImport

Content-Type > application/json
Authorization > key=<my app key>

Body =

{
"application": "com.myapp",
  "sandbox":false,
  "apns_tokens":["<my ios device token"]
}
 


and I get back

{
"results": [
 
{
"registration_token": "<fcm token>",
"apns_token": "<my ios device token",
"status": "OK"
}
]
}
 


Now when i try to send a message.... i get back an error "InvalidApnsCredential" .... so getting closer...

so trying to figure if my p12 file is bad.

Edited by: steven chesser on Mar 30, 2017 2:19 PM
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 30, 2017 10:02 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:
Got my .p12 file uploaded to Firebase ... forgot that part.

Now I can do a POST to

https://iid.googleapis.com/iid/v1:batchImport

Content-Type > application/json
Authorization > key=<my app key>

Body =
 
{
"application": "com.myapp",
  "sandbox":false,
  "apns_tokens":["<my ios device token"]
}
 


and I get back
 
{
"results": [
 
{
"registration_token": "<fcm token>",
"apns_token": "<my ios device token",
"status": "OK"
}
]
}
 


Now when i try to send a message.... i get back an error "InvalidApnsCredential" .... so getting closer...

so trying to figure if my p12 file is bad.

Went through the process again .... got the .p12 file re-created and uploaded ... same message :(
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 31, 2017 2:45 AM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

Went through the process again .... got the .p12 file re-created and uploaded ... same message :(

Making sure I have push notifications all sorted is on my to-do list, so I'll push (pun intended) it up for this
weekend, so I may have an answer for you.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 31, 2017 7:51 AM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
steven chesser wrote:

Went through the process again .... got the .p12 file re-created and uploaded ... same message :(

Making sure I have push notifications all sorted is on my to-do list, so I'll push (pun intended) it up for this
weekend, so I may have an answer for you.

--

Excellent :) .... I thought I was close ... but I think I am missing a step... I think there is a step to register the device with APNS for my app?
And that doing the Device Token to FCM token isn't enough.

Just having a rough time finding those details. Hard part is, no one in the company I work for has ever done remote notifications in Xcode (or at all in general)... So I can't ask them for help on the subject :(
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 31, 2017 3:35 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

Excellent :) .... I thought I was close ... but I think I am missing a step... I think there is a step to register
the device with APNS for my app? And that doing the Device Token to FCM token isn't enough.

Before going too headlong into this today, can you check whether your APNs certificate has not expired? You can check
in FCM, by going to (sign in if necessary):

https://console.firebase.google.com

Then select the project, click the little cog icon in the top left next to "Overview", click Project Settings, then
select Cloud Messaging. The APNs certificate details are in the iOS app config section.

If it has expired, you'll need to go to:

https://developer.apple.com/account

Sign in with the Apple ID that is used to manage your certificates, select Certificates, IDs and Profiles, select All
Certificates, and it will list the certificates you have with Apple. Click the + button at top right, select the
certificate type (eg Development, APNs) and follow the bouncing ball.

Once the certificate is generated, you can download it onto your Mac, open the Keychain Access app, import the
certificate by dragging the file onto the Keychain Access app, then follow the instructions from step 7, here:

https://www.mobiloud.com/help/knowledge-base/how-to-export-push-notification-certificate-p12/

To create the .p12 file that FCM uses.

Alternatively, get your Xcode people to regnerate the certificate etc :-)

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 31, 2017 10:51 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
steven chesser wrote:

Excellent :) .... I thought I was close ... but I think I am missing a step... I think there is a step to register
the device with APNS for my app? And that doing the Device Token to FCM token isn't enough.

Before going too headlong into this today, can you check whether your APNs certificate has not expired? You can check
in FCM, by going to (sign in if necessary):

https://console.firebase.google.com

Then select the project, click the little cog icon in the top left next to "Overview", click Project Settings, then
select Cloud Messaging. The APNs certificate details are in the iOS app config section.

If it has expired, you'll need to go to:

https://developer.apple.com/account

Sign in with the Apple ID that is used to manage your certificates, select Certificates, IDs and Profiles, select All
Certificates, and it will list the certificates you have with Apple. Click the + button at top right, select the
certificate type (eg Development, APNs) and follow the bouncing ball.

Once the certificate is generated, you can download it onto your Mac, open the Keychain Access app, import the
certificate by dragging the file onto the Keychain Access app, then follow the instructions from step 7, here:

https://www.mobiloud.com/help/knowledge-base/how-to-export-push-notification-certificate-p12/

To create the .p12 file that FCM uses.

Alternatively, get your Xcode people to regnerate the certificate etc :-)

We literally just made these 2 days ago ... BUT I checked anyways :)

Firebase shows my .p12 file that I uploaded

Development APNs certificate
Certificate valid until
3/30/18, 5:35 PM
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2017 3:32 AM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

We literally just made these 2 days ago ... BUT I checked anyways :)

Firebase shows my .p12 file that I uploaded

Development APNs certificate
Certificate valid until
3/30/18, 5:35 PM

OK, I've been out today (Bali time), so will be looking at this tonight.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2017 7:34 AM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

We literally just made these 2 days ago ... BUT I checked anyways :)

D'Oh! I just realised you said that in an earlier message.

I'm doing pretty much the same process as you're doing, but mine is working: I just tested the whole process tonight.

I assume you're using the Notifications section in the Firebase console to (attempt to) send the messages?

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2017 12:29 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
steven chesser wrote:

We literally just made these 2 days ago ... BUT I checked anyways :)

D'Oh! I just realised you said that in an earlier message.

I'm doing pretty much the same process as you're doing, but mine is working: I just tested the whole process tonight.

I assume you're using the Notifications section in the Firebase console to (attempt to) send the messages?

Correct... I've used the Firebase Console to try and send to my iOS device. And it comes back failed. Doesn't say why.

Then tried doing the POST call too, and I get the "InvalidApnsCredential" response.

So not sure what is goofed up then :(
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2017 2:35 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

Correct... I've used the Firebase Console to try and send to my iOS device. And it comes back failed. Doesn't say why.

If you hover the mouse over "Failed" in the Status column, it should tell you.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2017 4:09 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
steven chesser wrote:

Correct... I've used the Firebase Console to try and send to my iOS device. And it comes back failed. Doesn't say why.

If you hover the mouse over "Failed" in the Status column, it should tell you.

Strange .. not ALL of them work when I hover over.... Anyways..

Last attempt shows "Unregistered registration token"
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2017 4:35 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

Last attempt shows "Unregistered registration token"

That's an odd one, especially if your token registration is successful. You could try deleting the app from the device,
and have the app "redo" the token registration.

You might want to check the full response from the call, in case there's something out of the ordinary, but usually if
it gives you a valid FCM token, it should be able to be used for sending a message to the device.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 2, 2017 10:29 AM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
steven chesser wrote:

Last attempt shows "Unregistered registration token"

That's an odd one, especially if your token registration is successful. You could try deleting the app from the device,
and have the app "redo" the token registration.

You might want to check the full response from the call, in case there's something out of the ordinary, but usually if
it gives you a valid FCM token, it should be able to be used for sending a message to the device.

--

Posted earlier ... but this is what I get back
Body =
 
 {
 "application": "com.myapp",
   "sandbox":false,
   "apns_tokens":["<my ios device token"]
 }
 
 


and I get back
 
 {
 "results": [
 
 {
 "registration_token": "<fcm token",
 "apns_token": "<my ios device token",
 "status": "OK"
 }
 ]
 }
 
 


nothing else in the response looks like an issue.

Do you have standalone test programs written? Only thing I can think of is something is goofed SOMEWHERE and not sticking out... but I can't figure out what the heck is going on.

Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 2, 2017 5:33 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

Do you have standalone test programs written?

I've created a Github project, here:

https://github.com/DelphiWorlds/PushClient

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 2, 2017 6:16 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
steven chesser wrote:

Do you have standalone test programs written?

I've created a Github project, here:

https://github.com/DelphiWorlds/PushClient

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

Excellent thanks! I will check this out once Embarcadero finally bumps my install count :(
Swapping back in the old hard drive a pain.

Similar-ish on what I was trying to accomplish myself ...so still not sure what my problem is yet :)

Thanks again and I'll let you know hopefully by tomorrow... as long as they fix my install limit by then ....
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 3, 2017 2:57 PM   in response to: steven chesser in response to: steven chesser
DW.GlobalDefines.inc is missing but trying it now....

Edited by: steven chesser on Apr 3, 2017 3:02 PM
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 3, 2017 3:51 PM   in response to: steven chesser in response to: steven chesser
Good news... It works with my iOS device! :)

To be honest, I am not 100% sure what you are doing yet that I wasn't.

BUT... only thing I am not sure of ... using the Firebase console to send the messages. Even tho I am seeing them on
my iOS & Android device, Firebase still lists it as "failed" with "Unregistered registration token"

I am unsure what the exactly means...

Oddly tho it is working, so I am happy about that... thank you very much! I have much more testing to play with on both devices now using
your stand alone app.

1) I need to read up on Android services ... to write in this test project, a deal so I can receive the full message text when app isn't running?

2) It appears the notification on the iOS side works even without the app running it looks? So maybe don't need to do anything?

So ill play with this over the next few days now that I am back up and running... thanks again!
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 3, 2017 4:22 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

1) I need to read up on Android services ... to write in this test project, a deal so I can receive the full message
text when app isn't running?
2) It appears the notification on the iOS side works even without the app running it looks? So maybe don't need to do
anything?

I haven't progressed that far. Maybe I'll wait for you? ;-)

So ill play with this over the next few days now that I am back up and running... thanks again!

I have a requirement for this to all work anyway, and I wanted to make it public, however you're welcome!

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 3, 2017 8:24 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
steven chesser wrote:

1) I need to read up on Android services ... to write in this test project, a deal so I can receive the full message
text when app isn't running?
2) It appears the notification on the iOS side works even without the app running it looks? So maybe don't need to do
anything?

I haven't progressed that far. Maybe I'll wait for you? ;-)

So ill play with this over the next few days now that I am back up and running... thanks again!

I have a requirement for this to all work anyway, and I wanted to make it public, however you're welcome!

--

Used this demo @ https://www.youtube.com/watch?v=0mD3WLK8FYc

I can create the "service" .... that basically does nothing ... but it shows.

But once I start trying to add code and add the service back again.

"Unit "Unit2.pas" is incompatible with the FMX framework used by the project.

Adding it may result in compilation errors or unexpected behavior. Continue?"

Ill have to play more over the next few days ... I guess under services certain things can and can't be done....

May have to split the code? so that all the HTTP stuff, ect is split out and not compiled into the service? Not 100% sure yet.... Still trying to watch videos and read up what I can...

I am probably just missing or doing something stupid like usual.... :-/
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 5, 2017 8:34 PM   in response to: steven chesser in response to: steven chesser
Haven't gotten to far on Android service to get the notification and show via the notification center.

As soon as I add your units to the service, the program freezes when starting the service. Don't even need code IN the service to start anything. Just having them
in the uses locks it up.

Trying to use monitor.bat but haven't quite figured out its output to tell me whats going on yet.

So not sure if just can't be done here ... or like usual.. goofing something up.
Markus Humm

Posts: 4,865
Registered: 11/9/03
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 6, 2017 10:26 AM   in response to: steven chesser in response to: steven chesser
Am 06.04.2017 um 05:34 schrieb steven chesser:
Haven't gotten to far on Android service to get the notification and show via the notification center.

As soon as I add your units to the service, the program freezes when starting the service. Don't even need code IN the service to start anything. Just having them
in the uses locks it up.

Trying to use monitor.bat but haven't quite figured out its output to tell me whats going on yet.

So not sure if just can't be done here ... or like usual.. goofing something up.

Hello,

do these added units have anything in initialization section?
If yes, what?

Can a log.d('init done'); in those initialization sections maybe help to
see in logcat how far it is getting?

Greetings

Markus
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 6, 2017 11:22 AM   in response to: Markus Humm in response to: Markus Humm
Markus Humm wrote:
Am 06.04.2017 um 05:34 schrieb steven chesser:
Haven't gotten to far on Android service to get the notification and show via the notification center.

As soon as I add your units to the service, the program freezes when starting the service. Don't even need code IN the service to start anything. Just having them
in the uses locks it up.

Trying to use monitor.bat but haven't quite figured out its output to tell me whats going on yet.

So not sure if just can't be done here ... or like usual.. goofing something up.

Hello,

do these added units have anything in initialization section?
If yes, what?

Can a log.d('init done'); in those initialization sections maybe help to
see in logcat how far it is getting?

No initialization sections in either unit ...

I added init sections to both and added log.d , never gets that far it seems.
And not really sure while looking at Monitor.bat where the freeze up is happening.

I rebuilt the service.. removed it from main project.. added it back, and I get this

"Unit "ServiceDM.pas" is incompatible with the FMX framework used by the project.

Adding it may result in compilation errors or unexpected behavior. Continue? "

Doesn't tell you WHAT is incompatible.

If i remake the service with nothing in it other than setting the StartCommand to make it a START_STICKY
it runs fine and no error about being incompatible .... so it must be another unit somewhere that doesn't play happy.
Markus Humm

Posts: 4,865
Registered: 11/9/03
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 7, 2017 9:43 AM   in response to: steven chesser in response to: steven chesser
Am 06.04.2017 um 20:22 schrieb steven chesser:
Markus Humm wrote:

Hello,

do these added units have anything in initialization section?
If yes, what?

Can a log.d('init done'); in those initialization sections maybe help to
see in logcat how far it is getting?

No initialization sections in either unit ...

I added init sections to both and added log.d , never gets that far it seems.
And not really sure while looking at Monitor.bat where the freeze up is happening.

I rebuilt the service.. removed it from main project.. added it back, and I get this

"Unit "ServiceDM.pas" is incompatible with the FMX framework used by the project.

Adding it may result in compilation errors or unexpected behavior. Continue? "

Doesn't tell you WHAT is incompatible.

If i remake the service with nothing in it other than setting the StartCommand to make it a START_STICKY
it runs fine and no error about being incompatible .... so it must be another unit somewhere that doesn't play happy.

Hello,

Android services issues might be better dicussed in the Android specific
group. Maybe someone over there knows a reason for your issue.

Greetings

Markus
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 7, 2017 2:56 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

"Unit "ServiceDM.pas" is incompatible with the FMX framework used by the project.

That warning is usually due to the ClassGroup property of the datamodule being set to Vcl.Controls.TControl

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 8, 2017 11:35 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
steven chesser wrote:

"Unit "ServiceDM.pas" is incompatible with the FMX framework used by the project.

That warning is usually due to the ClassGroup property of the datamodule being set to Vcl.Controls.TControl

--

Appears it can get changed by some controls dropping on the datamodule? .. Noticed it goes from "FMX.Controls.TControl" to blank sometimes too. So I just set it back.

I got it to finally quit locking/freezing up by the above change... but the service code to handle the notifications doesn't seem to run. I assume just lack of knowing where to put the
code and maybe needing some loop? to keep things going maybe?
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2017 6:27 AM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

but the service code to handle the notifications doesn't seem to run. I assume just lack of knowing where to put the
code and maybe needing some loop? to keep things going maybe?

Where is the code located that handles the notifications? Do you have an example?

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 10, 2017 9:28 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
steven chesser wrote:

but the service code to handle the notifications doesn't seem to run. I assume just lack of knowing where to put the
code and maybe needing some loop? to keep things going maybe?

Where is the code located that handles the notifications? Do you have an example?

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

I know this is wrong ... but haven't had time to read up much lately and test ( dealing with a bad family situation and been wrapped up in that for past few days )

..
  private
    FPushClient: TPushClient;
...
 
function TdmService.AndroidServiceStartCommand(const Sender: TObject;
  const Intent: JIntent; Flags, StartId: Integer): Integer;
begin
  Result := TJService.javaclass.START_STICKY;
  
  // 
  FPushClient := TPushClient.Create;
  FPushClient.GCMAppID := cFCMSenderID;
  FPushClient.ServerKey := cFCMServerKey;
  FPushClient.BundleID := cFCMBundleID;
  FPushClient.OnChange := PushClientChangeHandler;
  FPushClient.OnReceiveNotification := PushClientReceiveNotificationHandler;
  FPushClient.Active := True;
end;
 
procedure TdmService.ShowAndroidNotification(MessageText: string;
NotificationNumber: Integer);
var
  NotificationCenter: TNotificationCenter;
  Notification: TNotification;
begin
  // THIS IS NOT PARSING THE JSON CODE YET TO SPLIT IT UP BUT NOT WORRIED ABOUT THAT YET AS THIS NEVER EVEN GETS RAN 
  NotificationCenter := TNotificationCenter.Create(nil);
  try
    Notification := NotificationCenter.CreateNotification;
    try
      Notification.Name := MessageText;
      Notification.AlertBody := MessageText;
      Notification.Title := MessageText;
      Notification.EnableSound := false;
      Notification.Number := NotificationNumber;
      NotificationCenter.ApplicationIconBadgeNumber := NotificationNumber;
      NotificationCenter.PresentNotification(Notification);
    finally
      Notification.DisposeOf;
    end;
  finally
    NotificationCenter.Free;
    NotificationCenter.DisposeOf;
  end;
end;
 
procedure TdmService.PushClientReceiveNotificationHandler(Sender: TObject;
const ANotification: TPushServiceNotification);
begin
  ShowAndroidNotification(ANotification.DataObject.ToString, 0);
end;
 
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 12, 2017 2:43 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

I know this is wrong ... but haven't had time to read up much lately and test ( dealing with a bad family situation
and been wrapped up in that for past few days )

I've started to look at this today, however it is not going well.

I started from the PushClient Demo project, and started in Tokyo. Probably a bad idea in hindsight, because it appears
Android services are totally broken in Tokyo. I'll check this later.

I reverted back to Berlin, however I'm having trouble with Android reporting that the app supposedly isn't responding,
so I'll start a project from scratch this evening and see how that goes.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Markus Humm

Posts: 4,865
Registered: 11/9/03
Re: Anyone get iOS and Firecloud Messaging working? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 13, 2017 11:57 PM   in response to: Dave Nottage in response to: Dave Nottage
Am 12.04.2017 um 23:43 schrieb Dave Nottage (TeamB):
steven chesser wrote:

I know this is wrong ... but haven't had time to read up much lately and test ( dealing with a bad family situation
and been wrapped up in that for past few days )

I've started to look at this today, however it is not going well.

I started from the PushClient Demo project, and started in Tokyo. Probably a bad idea in hindsight, because it appears
Android services are totally broken in Tokyo. I'll check this later.

I reverted back to Berlin, however I'm having trouble with Android reporting that the app supposedly isn't responding,
so I'll start a project from scratch this evening and see how that goes.

Hello,

about the broken Android services: did you check that there is a QP
report about that already? If not, do you have a reproducible case and
can report it?

Greetings

Markus
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 14, 2017 2:10 AM   in response to: Markus Humm in response to: Markus Humm
Markus Humm wrote:

about the broken Android services: did you check that there is a QP
report about that already? If not, do you have a reproducible case and
can report it?

No on both counts. As per my message, I'm yet to check, and still haven't, but will do

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 14, 2017 11:08 AM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
Markus Humm wrote:

about the broken Android services: did you check that there is a QP
report about that already? If not, do you have a reproducible case and
can report it?

No on both counts. As per my message, I'm yet to check, and still haven't, but will do

Be interesting what you find ... i myself with Berlin was getting the no response deal... but was unable
to track down what the problem was.
Markus Humm

Posts: 4,865
Registered: 11/9/03
Re: Anyone get iOS and Firecloud Messaging working? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 15, 2017 3:56 AM   in response to: Dave Nottage in response to: Dave Nottage
Am 14.04.2017 um 11:10 schrieb Dave Nottage (TeamB):
Markus Humm wrote:

about the broken Android services: did you check that there is a QP
report about that already? If not, do you have a reproducible case and
can report it?

No on both counts. As per my message, I'm yet to check, and still haven't, but will do

Sounds still good. Thanks and enjoy easter!

Markus
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 14, 2017 8:01 PM   in response to: Markus Humm in response to: Markus Humm
Markus Humm wrote:

about the broken Android services: did you check that there is a QP
report about that already? If not, do you have a reproducible case and
can report it?

This is the report for Android services and Tokyo:

https://quality.embarcadero.com/browse/RSP-17857

I'm still working out ways of making the push client work with a service.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 14, 2017 8:54 PM   in response to: Dave Nottage in response to: Dave Nottage
I wrote:

This is the report for Android services and Tokyo:

https://quality.embarcadero.com/browse/RSP-17857

I'm still working out ways of making the push client work with a service.

The above issue also applies to Berlin; it just crashes differently. For this reason, it appears it is impossible to
use anything in a service that refers to FMX.Types, either directly or indirectly, which includes push notifications.

Now I'm having trouble making my Android demo app (without the Android service included) receive push notifications at
all

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 14, 2017 9:39 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:

Now I'm having trouble making my Android demo app (without the Android service included) receive push notifications at
all

Helps to put the correct value in the Package Name field in the version info :-)

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Markus Humm

Posts: 4,865
Registered: 11/9/03
Re: Anyone get iOS and Firecloud Messaging working? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 15, 2017 3:57 AM   in response to: Dave Nottage in response to: Dave Nottage
Am 15.04.2017 um 05:54 schrieb Dave Nottage (TeamB):
I wrote:

This is the report for Android services and Tokyo:

https://quality.embarcadero.com/browse/RSP-17857

I'm still working out ways of making the push client work with a service.

The above issue also applies to Berlin; it just crashes differently. For this reason, it appears it is impossible to
use anything in a service that refers to FMX.Types, either directly or indirectly, which includes push notifications.

Now I'm having trouble making my Android demo app (without the Android service included) receive push notifications at
all

Would that also apply to d.log('my message'); which is afaik in
FMX.types? Because if, logging in a service would be hard to do and for
debugging it would be a big hinderance.

Greetings

Markus
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 16, 2017 12:14 AM   in response to: Markus Humm in response to: Markus Humm
Markus Humm wrote:

Would that also apply to d.log('my message'); which is afaik in
FMX.types? Because if, logging in a service would be hard to do and for
debugging it would be a big hinderance.

Yes, it does apply to that, however logging is easily worked around by making calls direct to LOGI. What is not easily
worked around is the notifications reliance on the FMX.Types unit

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Markus Humm

Posts: 4,865
Registered: 11/9/03
Re: Anyone get iOS and Firecloud Messaging working? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 16, 2017 12:46 AM   in response to: Dave Nottage in response to: Dave Nottage
Am 16.04.2017 um 09:14 schrieb Dave Nottage (TeamB):
Markus Humm wrote:

Would that also apply to d.log('my message'); which is afaik in
FMX.types? Because if, logging in a service would be hard to do and for
debugging it would be a big hinderance.

Yes, it does apply to that, however logging is easily worked around by making calls direct to LOGI. What is not easily
worked around is the notifications reliance on the FMX.Types unit

Yes I know that I can work around d.log ;-)
I implemented a more powerfull wrapper around that API myself
already some time ago ;-)
But it's annoying none the less!

Greetings

Markus
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 18, 2017 11:38 AM   in response to: Markus Humm in response to: Markus Humm
Markus Humm wrote:
Am 16.04.2017 um 09:14 schrieb Dave Nottage (TeamB):
Markus Humm wrote:

Would that also apply to d.log('my message'); which is afaik in
FMX.types? Because if, logging in a service would be hard to do and for
debugging it would be a big hinderance.

Yes, it does apply to that, however logging is easily worked around by making calls direct to LOGI. What is not easily
worked around is the notifications reliance on the FMX.Types unit

Yes I know that I can work around d.log ;-)
I implemented a more powerfull wrapper around that API myself
already some time ago ;-)
But it's annoying none the less!

I guess I have to ask, what dependencies in FMX.Types is the root of breaking things such as this? Kind of a buzz kill that this
seems to be the reason why the notifications won't work in a service :(
Markus Humm

Posts: 4,865
Registered: 11/9/03
Re: Anyone get iOS and Firecloud Messaging working? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 18, 2017 1:43 PM   in response to: steven chesser in response to: steven chesser
Am 18.04.2017 um 20:38 schrieb steven chesser:
Markus Humm wrote:
Am 16.04.2017 um 09:14 schrieb Dave Nottage (TeamB):
Markus Humm wrote:

Would that also apply to d.log('my message'); which is afaik in
FMX.types? Because if, logging in a service would be hard to do and for
debugging it would be a big hinderance.

Yes, it does apply to that, however logging is easily worked around by making calls direct to LOGI. What is not easily
worked around is the notifications reliance on the FMX.Types unit

Yes I know that I can work around d.log ;-)
I implemented a more powerfull wrapper around that API myself
already some time ago ;-)
But it's annoying none the less!

I guess I have to ask, what dependencies in FMX.Types is the root of breaking things such as this? Kind of a buzz kill that this
seems to be the reason why the notifications won't work in a service :(

Hello,

I've read something over the last few days about some variable in
system.pas which is nil in non GUI applications and makes using
components like TTimer in a service crash the service.

maybe that's related?

But I don't know. Afaik there is some QP report about that.

Greetings

Markus
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 18, 2017 1:53 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

I guess I have to ask, what dependencies in FMX.Types is the root of breaking things such as this? Kind of a buzz
kill that this seems to be the reason why the notifications won't work in a service :(

Whatever the case (and I really don't want to waste time finding out), I've now managed to make the PushClient start up
in a service, by "hacking" the FMX.Notification.Android unit. Next step is to work out how to make the notification be
sent to the handler.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Dave Nottage

Posts: 1,659
Registered: 1/7/00
Re: Anyone get iOS and Firecloud Messaging working? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 3, 2017 4:05 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

DW.GlobalDefines.inc is missing but trying it now....

Oops! Thanks for the heads up. As you've discovered, it doesn't need the .inc at the moment.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
loki loki

Posts: 710
Registered: 7/1/02
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 31, 2017 2:36 PM   in response to: steven chesser in response to: steven chesser
loki loki

Posts: 710
Registered: 7/1/02
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 31, 2017 2:45 PM   in response to: loki loki in response to: loki loki
On 4/1/2017 12:36 AM, loki loki wrote:

aaah ios :)
steven chesser

Posts: 395
Registered: 4/13/09
Re: Anyone get iOS and Firecloud Messaging working? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 31, 2017 2:57 PM   in response to: loki loki in response to: loki loki

Thats the one I posted already... I use it... works great for Android.. (other than I gotta learn how to do the Service side of things for when app isn't running)

But it doesn't cover any of the iOS side of things linking up to APNS with FCM. It has the one line for TPushService.TServiceNames.APS
but other than that, wasn't much there.

I even posted in the comments about iOS write up but that author won't be doing so.

I have almost working it seemed... but i get that "InvalidApnsCredential" message which I can't
figure out why or what that means exactly.. other than I am maybe missing a step of actually registering the app
on the device to APNS maybe ?
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02