Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Remote Notifications for iOS and Android? We got an expert here?



Permlink Replies: 21 - Last Post: Mar 29, 2017 7:31 PM Last Post By: steven chesser
steven chesser

Posts: 401
Registered: 4/13/09
Remote Notifications for iOS and Android? We got an expert here?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 27, 2017 3:49 PM
Using Berlin update 2

I've asked this once before .. but revisiting this.

I have an app that is on both iOS and Android.

This is a business type app. The users who would download it.. would configure it to talk to THEIR server at their location.
Could be 1.. could be 50 people or more at that location.

We have around 1600+ customers using our inventory software across the country. From big to small. Each location have unknown amount of people
working for them.

Each location owns their server.. their data.. they are 100% independent.

So...

I need a way to get my apps on both OS to recv remote notifications .... and I need some hand holding here.

1) Besides flipping a switch to enable remote notifications... how does the device link to the service at apple/google to know its tie to our app?

2) How does one location ( our customer using our inventory software ) .... know to talk their employee devices?

3) How does the location SEND that data to apple/google?

4) How would I make it UI wise on my Windows program... to select "Billy Bob" ... and send some notification to "Billy Bob" ... where did
this info come from to know that "Billy Bob" exists.. and whatever credientials to fire off to, to get him his notification?

It seems that we may have to write our own server sitting here... to accept all these messages from around the country?

To get some tid bit of info... and then fire it out to a device...

What info would need to be recevied ? What info would need to be fired out to the device?

How does the Link from Customer Server > Our Server > apple/google > user device happen?

I've looked for dozens of hours ... and I can't seem to wrap my head on how any of this truely works like how I "think" it should work.

Has anyone here actually done remote notifications? and if so... have you done it so you tackled this situation?

This isn't like Facebook.. where you talk to facebook.. facebook talks to you... this is like, 1600+ facebook servers.. all their own little universe,
and each facebook universe has to to talk to their own population.. totally unaware that theire are 1599+ other universes out there.

loki loki

Posts: 787
Registered: 7/1/02
Re: Remote Notifications for iOS and Android? We got an expert here?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 27, 2017 4:01 PM   in response to: steven chesser in response to: steven chesser
steven chesser

Posts: 401
Registered: 4/13/09
Re: Remote Notifications for iOS and Android? We got an expert here?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 27, 2017 4:23 PM   in response to: loki loki in response to: loki loki
loki loki wrote:
did you look at https://firebase.google.com/docs/cloud-messaging/ ?

I have to a small extent ... but it appears nothing in Delphi pre-made to drop in... so everything on both sides of the picture has to be 100% written from scratch?

I have yet to find anyone thats actually used anything to do anything. Or at least that I know of.

I assume in my case... each device gets/generates a token.. at some point.. then it can change too on some cases.

I would need the phone/tablet device... to get their token and then update the customers server database to store it..

Billy bob = Token1235
Jim bob = Token4534
Danny boy = Token1123

and so on..

So in my windows app.. I pick Jim bob... construct a message.. and fire it off to his device.. Token4534.

If Jim bob's token changes... it will be "wrong" until Jim bob's phone app (my app) picks up on this.. and updates this database keeping track of it.

steven chesser

Posts: 401
Registered: 4/13/09
Re: Remote Notifications for iOS and Android? We got an expert here?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 27, 2017 8:12 PM   in response to: steven chesser in response to: steven chesser
I used this ... and was able get something to work on android!

Got my Firebase / FCM setup...

Made my app show its token..

Took that token and put it into my test windows app.

And I got a notification on my Android device.

If the app is running.... you get your full fledge message through.
If not running, I just see my app Icon, but later down in this thread, it mentions I have to write an Android service for that to work.

Haven't tested iOS yet as no demo it seems for that, but maybe not much different I hope.

http://thundaxsoftware.blogspot.com/2017/01/firebase-cloud-messaging-with-delphi.html

My screenshot @ https://scontent-iad3-1.xx.fbcdn.net/v/t1.0-9/17553448_10212147576388354_2592349598059567528_n.jpg?oh=57f39db885d395eaf2cf1fe5b745e5ad&oe=59521C1F

top message is when my app was running.. i could show the text

bottom is when my app wasn't running.

Now if I can find a write up for hold my hand on iOS usage ......

Edited by: steven chesser on Mar 27, 2017 8:30 PM
Eli M

Posts: 1,346
Registered: 11/9/13
Re: Remote Notifications for iOS and Android? We got an expert here?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 27, 2017 10:44 PM   in response to: steven chesser in response to: steven chesser
steven chesser

Posts: 401
Registered: 4/13/09
Re: Remote Notifications for iOS and Android? We got an expert here?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 27, 2017 10:41 PM   in response to: steven chesser in response to: steven chesser
Came across this to try iOS ... but code doesn't seem to work for getting the iOS device token. Always blank.

https://community.embarcadero.com/answers/q-remote-message-notification-for-delphi-ios-apps-without-kinvey-parse

I am probably missing a few things.... working on getting my SSL certs from Apple dev ... having issue creating the CSR file needed.

There is a setting to enable LocalNotifications ... didnt see anything about Remote ones.

Edited by: steven chesser on Mar 27, 2017 10:41 PM
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 27, 2017 11:11 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

Came across this to try iOS ... but code doesn't seem to work for getting the iOS device token. Always blank.

From memory, it tries to get the token too early. The OnChange event of the service connection instance needs a handler
set, similar to the following:

procedure TForm1.ServiceConnectionChangeHandler(Sender: TObject; AChange: TPushService.TChanges);
begin
  if TPushService.TChange.DeviceToken in AChange then
    FDeviceToken := PushService.DeviceTokenValue[TPushService.TDeviceTokenNames.DeviceToken];
end;


Sorry I don't have more detail right now. It's part of a larger project. The code above should provide a clue, though.

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

Posts: 401
Registered: 4/13/09
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 28, 2017 1:00 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
steven chesser wrote:

Came across this to try iOS ... but code doesn't seem to work for getting the iOS device token. Always blank.

From memory, it tries to get the token too early. The OnChange event of the service connection instance needs a handler
set, similar to the following:

procedure TForm1.ServiceConnectionChangeHandler(Sender: TObject; AChange: TPushService.TChanges);
begin
  if TPushService.TChange.DeviceToken in AChange then
    FDeviceToken := PushService.DeviceTokenValue[TPushService.TDeviceTokenNames.DeviceToken];
end;


Sorry I don't have more detail right now. It's part of a larger project. The code above should provide a clue, though.

--

Still comes up as a blank DeviceToken :(

I can get the DeviceID .... but the token is always blank when this event triggers. I did ensure it IS getting to the point of populating FDeviceToken .... its just the
value set.. is blank.

I did go through the process of enabling my app for push notifications on the apple dev side. Made my keychain file.. uploaded it.. got a cert file and all that noise.

I think I did that whole process right.

But so far, still hitting a wall getting the Device Token....

there is also a pList file from google / FCM to download ... I downloaded it.. but no idea what to really do with it yet.. Only thing I could find was add it to the deployment in the .\
and call it a day... but that just seems odd to me I guess.

steven chesser

Posts: 401
Registered: 4/13/09
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 28, 2017 2:59 PM   in response to: steven chesser in response to: steven chesser
Video I watched @ https://www.youtube.com/watch?v=n_C5_GxQhk4

In XE7 thre is an option to enable push notifications... screen shot i took from this video

https://scontent.xx.fbcdn.net/v/t31.0-8/17505075_10212154888331148_3280709087542274369_o.jpg?oh=a6c76eadb4d11d8673e943187d793dc3&oe=5962523D

Now in Berlin this is what I have

https://scontent.xx.fbcdn.net/v/t1.0-9/17629785_10212154894011290_4678866986878983054_n.jpg?oh=105e7651f5f9094df6908a2066e5e5db&oe=5951ED27

So maybe my issue on iOS ... is not turning on push notification support in the app itself?

FMLocalNotificationPermission is already set to True ... is there Key/Value pair for Remote I need to put in manually?

Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 28, 2017 3:21 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

So maybe my issue on iOS ... is not turning on push notification support in the app itself?

Push Notifications Entitlements are for Android.

When the TAPSPushService is started, it calls registerForRemoteNotifications, at which point iOS should prompt you if
you want to receive push notifications. If that hasn't ever happened, it's not starting the "service".

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

Posts: 401
Registered: 4/13/09
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 28, 2017 11:34 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
steven chesser wrote:

So maybe my issue on iOS ... is not turning on push notification support in the app itself?

Push Notifications Entitlements are for Android.

When the TAPSPushService is started, it calls registerForRemoteNotifications, at which point iOS should prompt you if
you want to receive push notifications. If that hasn't ever happened, it's not starting the "service".

--

Well in the screen shot... it shows iOS ... and entitlement list , which shows receive push notifications.

Currently IN berlin ... we have "FMLocalNotificationPermission" to set.

I was pondering if there is something like this but for Remote Notifications?

If not, I am 100% at a loss on why I can't get a Device Token..

Other than I guess Berlin is 100% broke on this feature for iOS.
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2017 3:48 AM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

Other than I guess Berlin is 100% broke on this feature for iOS.

I can double check later, but I'm pretty sure I had it working on Berlin.

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

Posts: 401
Registered: 4/13/09
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2017 6:57 AM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
steven chesser wrote:

Other than I guess Berlin is 100% broke on this feature for iOS.

I can double check later, but I'm pretty sure I had it working on Berlin.

Only thing I can think of is there is still a problem on the Apple APNS setup of things / provision profiles / certs / ect ....

Apple makes things so damn difficult it drives me up the wall.

Spent about 8 hrs yesterday on this and got no where :(
steven chesser

Posts: 401
Registered: 4/13/09
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2017 10:05 AM   in response to: steven chesser in response to: steven chesser
Trying to use XCode ... ugh I can't stand it ....

Anyways .... I noticed when I enable Push Notifications it shows a check list it does

"Add the Push Notification feature to your App ID."

"Add the Push Notification entitlement to your entitlements file."

So it seems something has to be turned on app wise to allow it? If so... how :)

steven chesser

Posts: 401
Registered: 4/13/09
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2017 11:43 AM   in response to: steven chesser in response to: steven chesser
Was able to get an XCode app using my apps ID to show the Token ... so it HAS to be something in the Delphi side I am missing... but still can't find anything about it.
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2017 1:10 PM   in response to: steven chesser in response to: steven chesser
Am 29.03.2017 um 20:43 schrieb steven chesser:
Was able to get an XCode app using my apps ID to show the Token ... so it HAS to be something in the Delphi side I am missing... but still can't find anything about it.

Are you on SA (= maintenance)?
If yes you can file a direct ticket with EMBT and they will have
somebody take a look at it.

Greetings

Markus
steven chesser

Posts: 401
Registered: 4/13/09
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2017 5:51 PM   in response to: Markus Humm in response to: Markus Humm
Markus Humm wrote:
Am 29.03.2017 um 20:43 schrieb steven chesser:
Was able to get an XCode app using my apps ID to show the Token ... so it HAS to be something in the Delphi side I am missing... but still can't find anything about it.

Are you on SA (= maintenance)?
If yes you can file a direct ticket with EMBT and they will have
somebody take a look at it.

Been trying to get my password reset for 2 days on SalesForce site I last used... haven't gotten an email yet to reset it to something new :(
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2017 4:13 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:

Push Notifications Entitlements are for Android.

My bad: they apply to both. I just checked what should be being inserted into the entitlements file, and it does need
this:

  <key>aps-environment</key>
  <string>development</string>  (or: <string>production</string>)


It seems the option has been removed from the iOS project options between that demo you saw and Berlin? One way around
it may be to manually insert it in the Entitlement.TemplateIOS.xml file, where:

  <%pushNotificationKey%>


is. (i.e. replace that part with the text described above)

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

Posts: 401
Registered: 4/13/09
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2017 5:47 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
Dave Nottage wrote:

Push Notifications Entitlements are for Android.

My bad: they apply to both. I just checked what should be being inserted into the entitlements file, and it does need
this:

  <key>aps-environment</key>
  <string>development</string>  (or: <string>production</string>)


It seems the option has been removed from the iOS project options between that demo you saw and Berlin? One way around
it may be to manually insert it in the Entitlement.TemplateIOS.xml file, where:

  <%pushNotificationKey%>


is. (i.e. replace that part with the text described above)

All the demos seem to be XE7 and older ... XE8 looks to have changed things up. Which is the oldest I have currently installed (well other than D7)

I did already today modifying the Entitlement.TemplateiOS.xml file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <%getTaskAllowKey%>
    <%applicationIdentifier%>
    <key>aps-environment</key>
    <string>development</string>
    <%keychainAccessGroups%>
</dict>
</plist>


Which this won't deploy... generates an "e8008016" error code.

Which from here @ http://docwiki.embarcadero.com/RADStudio/Berlin/en/Troubleshooting:_Cannot_Deploy_to_the_iOS_Device

"e8008016: Possible causes are:
You have set entitlements options for iOS that are not permitted by the provisioning profile installed in the target device.
If you use Remote notifications in your application, ensure that you have set the proper application services for the provisioning profile installed in the target device.
If you use "Auto" in Provisioning Options to sign your application, verify that the signing data is valid for your target device. You may need to select a specific Developer Certificate Name and Provision Profile.
Make sure that you set the right value for the CFBundleIdentifier fields on the Provisioning page for the target iOS platform. See Creating an App ID for Your Application."


I am gonna "assume" my app provision profiles work and all that... as my XCode demo works on getting the token.

If I revert the xml file back to original text ... then it deploys... but no token.

I even made a new application to test against... staging it all up.. same results.

Edited by: steven chesser on Mar 29, 2017 5:47 PM
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit] [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2017 5:58 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

Which this won't deploy... generates an "e8008016" error code.

I am gonna "assume" my app provision profiles work and all that... as my XCode demo works on getting the token.

Might be a silly question, however are you sure your Xcode demo using the same profile? I have a test project set up
that I'm going to check again this morning, but I thought I'd ask now anyway :-)

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

Posts: 1,850
Registered: 1/7/00
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit] [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2017 6:23 PM   in response to: Dave Nottage in response to: Dave Nottage
I wrote:

I have a test project set up
that I'm going to check again this morning, but I thought I'd ask now anyway..

I have now run my test project, and it works as expected.

* My Entitlement.TemplateIOS.xml did not need modification (as per my earlier message)

* The resulting entitlements file (which can be found in the [] folder on your Mac), looks like this (edited to remove
private info):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	
	<key>application-identifier</key>
	<string>XXXXXXX.com.codasart.mm</string>
	
 
<key>get-task-allow</key><true/><key>com.apple.developer.team-identifier</key><string>XXXXXXX</string><key>aps-environme
nt</key><string>development</string><key>keychain-access-groups</key>
	<array>
		<string>XXXXXXX.com.codasart.mm</string>
	</array>
</dict>
</plist>


It appears the IDE inserts the push notification entitlement based on the profile that is being applied to the project
(see the Provisioning section of the Project Options), which explains why it no longer appears in the Entitlements
section of the Project Options.

That you received that error message when you inserted it manually is an strong indication that the profile you're
applying to the project does not have the entitlement.

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

Posts: 401
Registered: 4/13/09
Re: Remote Notifications for iOS and Android? We got an expert here? [Edit] [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2017 7:31 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
I wrote:

I have a test project set up
that I'm going to check again this morning, but I thought I'd ask now anyway..

I have now run my test project, and it works as expected.

* My Entitlement.TemplateIOS.xml did not need modification (as per my earlier message)

* The resulting entitlements file (which can be found in the [] folder on your Mac), looks like this (edited to remove
private info):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	
	<key>application-identifier</key>
	<string>XXXXXXX.com.codasart.mm</string>
	
 
<key>get-task-allow</key><true/><key>com.apple.developer.team-identifier</key><string>XXXXXXX</string><key>aps-environme
nt</key><string>development</string><key>keychain-access-groups</key>
	<array>
		<string>XXXXXXX.com.codasart.mm</string>
	</array>
</dict>
</plist>


It appears the IDE inserts the push notification entitlement based on the profile that is being applied to the project
(see the Provisioning section of the Project Options), which explains why it no longer appears in the Entitlements
section of the Project Options.

That you received that error message when you inserted it manually is an strong indication that the profile you're
applying to the project does not have the entitlement.

You are probably 100% correct ....

I noticed in XCode it was set to auto sign (our Xcode guy made me the app) ... which created a bunch of magic for me. ( I dont use XCode so its all magic to me )

When I set it to profile in Xcode to the one I usually use in Delphi ... the status shows that provision profile doesn't include aps-environment ....

I am not the only one that uses this iOS dev account... I noticed now there is like 30+ provision profiles to choose from now vs 2-3 we had before, at least a few weeks ago when I last had to look at this app.

So i'll have to make sure I guess to have our head iOS/XCode guy in the company that runs this all figure out what they have done now.

Which I am sure this gonna be a kick in the nards .... our app is out there already... but profile they had me use maybe originally wasn't right? So totally lost now.. sigh..

Being its a company account.. I just can't jump on the apple dev site and click away without worry... as I could affect 100 other apps for I all i know.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02