Firebase notifications "tied" to one App

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Firebase notifications "tied" to one App

Post by simon.schvartzman » Fri Jul 12, 2019 7:05 pm

HI sphere, thank you for sharing your standalone settings. Here are mine:
ss2.jpg
The main differences I see are:
  • You are using LC 9.0.5 (I've tried and made no difference)
  • Your minimum Android Version is 7.1 while mine is 6.0 (that's the device I have available)
  • I'm not using a key to sign
  • I'm loading to a physical device instead of using the emulator
Are you able to identify any other thing that could be causing the trouble?

Anyway many thanks for your efforts to help me, moving forward I'll be chasing Panos & Company regarding the bug report...
Simon
________________________________________
To ";" or not to ";" that is the question

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Firebase notifications "tied" to one App

Post by sphere » Fri Jul 12, 2019 9:52 pm

Hi Simon,

the screen of me was lc950dp1, but it should not matter.
Also it should not matter the version of Android as i test on 4.4.2 & 8.1 and previous on a Android 6.
A sign key should also not matter for testing.
I tested both on real devices and emulator, on both a key should appear.
Also the minimum Android i previous used was 4.3.0 and also worked.

So mus be something different we are unable to lay our finger on. But i'm almost sure it's not lc904/lc903 as i used these versions too, and it worked.

Hopefully they will check your addition to the report and figure out what it could be. Maybe you have to send your test stack.

Regards,
Sphere

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Firebase notifications "tied" to one App

Post by simon.schvartzman » Mon Jul 22, 2019 7:48 pm

Just to close the thread as it may be helpful for future readers, the whole problem was related with the use of the answer command as explained by Panos in the following post

https://quality.livecode.com/show_bug.cgi?id=21259
Simon
________________________________________
To ";" or not to ";" that is the question

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Firebase notifications "tied" to one App

Post by sphere » Mon Jul 22, 2019 9:24 pm

yeah i've read it.
But it's a bit strange, because you had the problem already without the answer command, which was just to see if the token was there or not.
Although the solution Panos gave is a non blocking one, it's still strange why it did not work in the first place, even without the answer command.

I'm going to use the solution from Panos too as it is non blocking)may i get such issue for a next project), but i never had problems using the answer command just to check for the token. (the token is already created and after creation shown).

But if it's working for you now, then it's ok :)

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Firebase notifications "tied" to one App

Post by simon.schvartzman » Mon Jul 22, 2019 9:30 pm

Hi sphere, yes I agree with you, but after more than a week hitting my head into the wall, now that it works I will let it be without any further discussions...

Best!
Simon
________________________________________
To ";" or not to ";" that is the question

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Firebase notifications "tied" to one App

Post by sphere » Mon Jul 22, 2019 9:41 pm

Never change/argue a working system :mrgreen:

Tchau!

EddieLee
Posts: 118
Joined: Thu Oct 25, 2018 1:06 pm

Re: Firebase notifications "tied" to one App

Post by EddieLee » Thu Feb 25, 2021 9:06 pm

Hi all, chanced upon this post when I was searching for help on push notifications, can I check does the current lesson on livecode still works for you guys or do I have to change something? Because if I follow exactly, it doesn’t work at all.
Eddie :D

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Firebase notifications "tied" to one App

Post by simon.schvartzman » Thu Feb 25, 2021 9:40 pm

Hi EddieLee, the short answer is "Yes" it works for me.

The long answer is: there are many details to take into account as described on the Lesson Comments and in this thread itself.

I'd suggest you start with the very basic: check if you device gets registered and you get the token and build from there

Good luck (Push notifications has been a nightmare for me)
Simon
________________________________________
To ";" or not to ";" that is the question

EddieLee
Posts: 118
Joined: Thu Oct 25, 2018 1:06 pm

Re: Firebase notifications "tied" to one App

Post by EddieLee » Fri Feb 26, 2021 5:48 am

Hi Simon,
simon.schvartzman wrote:
Thu Feb 25, 2021 9:40 pm

I'd suggest you start with the very basic: check if you device gets registered and you get the token and build from there.
Would you mind helping me with it? Maybe through here or through message. My token and device get registered but unable to receive push noti. My problem would probably be on the fire base side? Did you follow the steps exactly the same and created GCM? Or did you go ahead and went for FCM maybe I created my project wrongly on FCM? How do I go about doing it
Eddie :D

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Firebase notifications "tied" to one App

Post by simon.schvartzman » Fri Feb 26, 2021 10:41 am

I'll be happy to try to help.
I did my setup 2+ years ago and I don't recall if I went straight into FCM or not.
I would suggest we keep the communication here as it may be helpful for other users.
Next step would be for you to share your StandAlone and FCM screens (whitout your private data of course) and I will check how they compare with mine.
It will also be useful to share which versions are you running (LC, IDE platform, Device)
Simon
________________________________________
To ";" or not to ";" that is the question

EddieLee
Posts: 118
Joined: Thu Oct 25, 2018 1:06 pm

Re: Firebase notifications "tied" to one App

Post by EddieLee » Fri Feb 26, 2021 12:27 pm

Hi Simon,

After struggling to find out what’s the issue yesterday, I’ve decided to start everything from scratch by following through the lesson on livecode again. Thanks for hope you can guide me step by step.

https://lessons.livecode.com/m/4069/l/5 ... th-android

In the Google APIs library, should I enable FCM or GCM? Or should I not use Google APIs and straight to to FCM website instead?

Many thanks
Eddie
Eddie :D

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Firebase notifications "tied" to one App

Post by simon.schvartzman » Fri Feb 26, 2021 12:45 pm

In the Google APIs library, should I enable FCM or GCM? Or should I not use Google APIs and straight to to FCM website instead?
I don't remember touching the Google APIs at all. I just went straight to the FCM website.
Simon
________________________________________
To ";" or not to ";" that is the question

EddieLee
Posts: 118
Joined: Thu Oct 25, 2018 1:06 pm

Re: Firebase notifications "tied" to one App

Post by EddieLee » Fri Feb 26, 2021 12:54 pm

Hi Simon,
simon.schvartzman wrote:
Fri Feb 26, 2021 12:45 pm
I don't remember touching the Google APIs at all. I just went straight to the FCM website.
I have created a new project on FCM, used the server key as my API key and added my senderID into the push sender id of the standalone settings. While running on my device, i am able to get the device token number and have successfully emailed it to myself. Tried using the livecode lesson file to send a notification to me and after changing the notificationURL to "https://fcm.googleapis.com/fcm/send" it said that it was successfully but i still didnt receive a notification yet. My senderID is a 11 digit number and i read on previously it should be 12? Am i doing something wrong here? Im using LC 9.6 and testing on a hardware device running android version 10.

Also, how do i share my FCM screens and standalone settings screen here with you ?





Thanks!
Eddie
Eddie :D

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Firebase notifications "tied" to one App

Post by simon.schvartzman » Fri Feb 26, 2021 2:47 pm

Hi Eddie, to make things easier (hopefully) I'm going to share my screens and settings (in order to share a screen you have to add it in the Attachments tab below)
APIs.jpg
fb.jpg
standalone.jpg
There is another very important aspect to look at which is the routine used to actually send the notification. Below is the code I'm using, please take special note of the changed made at the end replacing "gcm" by "fcm"

Code: Select all

command pushNotificationAndroid pAPIKey, pDevices, pTitle, pBody, pBadge, pSound, pPayload
   local tDataA, tNotificationA, tNotification, tHeaders
   
   # build data element of notification
   put pTitle into tDataA["title"]
   put pBody into tDataA["body"]
   put pBadge into tDataA["badge_value"]
   put pSound = true into tDataA["play_sound"]
   put pPayload into tDataA["payload"]
   
   # build notification
   put tDataA into tNotificationA["data"]
   split pDevices with LF
   put pDevices into tNotificationA["registration_ids"]
   put "Splash21" into tNotificationA["collapse_key"]
   
   # create a JSON encoded message
   jsonEncode tNotificationA, tNotification
   
   # headers
   put "Content-Type: application/json" & LF into tHeaders
   put "Authorization: key=" & pAPIKey & LF after tHeaders
   set the HTTPHeaders to tHeaders
   
   # had a couple of errors that were resolved by setting/resetting this flag  :/
   libUrlSetSSLVerification false
   
   # send the notification
   # URL updated on 19 Feb 2018
   # changed by me on Aug 09 because the gcm call has been depreciated
   --post tNotification to url "https://gcm-http.googleapis.com/gcm/send"
   post tNotification to url "https://fcm.googleapis.com/fcm/send"
   return it
end pushNotificationAndroid
My senderID is a 11 digit number and i read on previously it should be 12?
Mine is a 12 digit number...
Can i also check do your server key has a semi colon at the start of the string?
Mine doesn't have a semi colon at the start...it looks like
AAAAzNoik....0KKQyxY5
Hope it helps...best luck!
Simon
________________________________________
To ";" or not to ";" that is the question

EddieLee
Posts: 118
Joined: Thu Oct 25, 2018 1:06 pm

Re: Firebase notifications "tied" to one App

Post by EddieLee » Fri Feb 26, 2021 3:04 pm

simon.schvartzman wrote:
Fri Feb 26, 2021 2:47 pm
Hi Eddie, to make things easier (hopefully) I'm going to share my screens and settings (in order to share a screen you have to add it in the Attachments tab below)

APIs.jpg


fb.jpg
Hi Simon, thanks for the clarification. Previously you said you didn’t not use Google APIs so I went straight to Firebase to create a project. But in the screenshots that you posted I saw that you had created a project in Google API AND Firebase. Do I need to link both of them together if so how should I go about doing it? Or do I just need to create a project on Google API, enable firebase then create the same project with the same name on firebase then get my key and senderID from there? Also, yours is 100% working now and there’s nothing that is bothering you?

Thanks!
Eddie
Eddie :D

Post Reply

Return to “Android Deployment”