Recent

Author Topic: Android Module Wizard  (Read 639078 times)

rsu333

  • Jr. Member
  • **
  • Posts: 58
Re: Android Module Wizard
« Reply #1230 on: June 28, 2021, 03:15:36 pm »
Your work is energetic for us.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1918
Re: Android Module Wizard
« Reply #1231 on: July 23, 2021, 11:07:13 pm »
Hi, All!

Now LAMW can handle "Firebase Cloud Messaging"  push notification!

NEW! "jsFirebasePushNotificationListener"  component

NEW!  demo:
AppCompatFirebasePushNotificationListenerDemo1

NEW! doc!
"how_to_handling_firebase_push_notification.txt"

Quote
How to: Handling Firebase Push Notification in LAMW  [warning: "beta" version ::  23-July-2021]
   (by jmpessoa)


0) Create your "AppCompat" [[theme]] project
   0.1)Put a "jsFirebasePushNotificationListener" component on form
        0.2)Go to lazarus menu and simply  "Run" --> "Build"

1) Login in your google acount [email or any....]

2) Go to "https://console.firebase.google.com/"

3) Create/Add a new Project   [ex: "MyOrg"]

4) Go to your "MyOrg" project and click "+Add app"

5) Click on Android Icon

6) In (page) "Add Firebase to your Android app":
   6.1) "Register App"
      6.1.1 ""Android package name"
         ex: org.lamw.appcompatfirebasepushnotificationlistenerdemo1

      6.1.2 CLICK the button "Register app"

   6.2) "Download config file"
                 get the "google-services.json" and put it in your LAMW project folder

        Done!

   (don't do anything more, LAMW takes care of it all for you!)

7) Active your Internet phone/device connection

8) Go to Lazarus menu "Run" --> "[LAMW] Build Android Apk and Run"

9) Go to "https://console.firebase.google.com/"

   9.1 Click the "MyOrg" project
   9.2 In the left panel/menu page go to "Engage" --> "Cloud Messaging"
   9.3 Click "New notification" Button
   9.4 Fill the form and click "Next"
   9.5 In the "Target" --> "selectan app"   [select your app package...] and "Next"
        9.6 In the "Scheduling" --> "Now"  and "Next"
        9.7 In the bottom page click the button "Review"
   9.8 "Publish"  !!!!


Congratulations!!!


10) Notes about your/custom Payload expected by LAMW component:
   [https://firebase.google.com/docs/cloud-messaging/concept-options?hl=en]

10.1 Notification Payload


{
"message":{
-    ...
     ...
    "notification":{
      "title" : "my message title",     // ---> "title" expected by LAMW
      "body" : "my message body"        // ---> "body"  expected by LAMW
    }
    ...
    ...
  }
}

Note: Notification messages are delivered to the notification tray when the app is in the background.
For apps in the foreground, messages are handled/delivery by a LAMW callback function for you !!!


10.2 Data Payload

{
  "message":{
    ...
    ...
    "data":{
      "title":"my message title",// ---> "title" expected by LAMW
      "body":"my message body",  // ---> "body" expected by LAMW
      "myKey1":"myValue1"        //free/custom
      "myKey2":"myValue2"        //free/custom
       ......                    //free/custom
    }
    ...
    ...
  }
}

Where myKey1, myKey2, .... are your free/custom key=value pairs ....

warning: from "data" messages only "title" and "body" are handled/delivery by the LAMW callback function for you
         but you can read all "data" when App is "waking up" by clicking in notification....

//by code:
Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.AndroidModule1ActivityCreate(Sender: TObject; intentData: jObject);
  2. var
  3.   data: TDynArrayOfString;
  4.   i, count: integer;
  5. begin
  6.   data:= jIntentManager1.GetBundleContent(intentData, '=');  //key=value
  7.   count:= Length(data);
  8.   for i:= 0 to count-1 do
  9.   begin
  10.      ShowMessage(data[i]);  //key=value
  11.   end;
  12. end;
  13.  

//and/or maybe:
Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.AndroidModule1NewIntent(Sender: TObject; intentData: jObject);
  2. var
  3.   data: TDynArrayOfString;
  4.   i, count: integer;
  5. begin
  6.   data:= jIntentManager1.GetBundleContent(intentData, '=');  //key=value
  7.   count:= Length(data);
  8.   for i:= 0 to count-1 do
  9.   begin
  10.      ShowMessage(data[i]);  //key=value
  11.   end;
  12. end;
  13.  

10.3 Mixing Notification and Data Payload

{
  "message":{
    ...
    "notification":{
      "title" : "my message title",     // ---> "title" expected by LAMW
      "body" : "my message body"        // ---> "body"  expected by LAMW
    }
    "data":{
      "myKey1":"myValue1"        //free/custom
      "myKey2":"myValue2"        //free/custom
       ......
    }
    ...
    ...
  }
}


10.4  WARNING: "beta" version ::  23-July-2021

10.5 References

https://firebase.google.com/docs/cloud-messaging/concept-options?hl=en


Thanks to All!
« Last Edit: August 09, 2021, 12:21:38 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Mongkey

  • Full Member
  • ***
  • Posts: 160
Re: Android Module Wizard
« Reply #1232 on: August 08, 2021, 10:45:55 am »
Is it posibble in near future LAMW modify firebase db? Just like FB4D  :)
Or just simply modifying by using javascript inside webview?

Thank you
« Last Edit: August 08, 2021, 11:11:51 am by Mongkey »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1918
Re: Android Module Wizard
« Reply #1233 on: August 09, 2021, 12:26:05 am »

Quote
Is it posibble in near future LAMW modify firebase db

Yes, we can try implement firebase "db" ...

But let's clarify:
jsFirebasePushNotificationListener component is about  "Firebase Cloud Messaging"  push notification!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Mongkey

  • Full Member
  • ***
  • Posts: 160
Re: Android Module Wizard
« Reply #1234 on: August 09, 2021, 01:48:28 am »
Ok, thank you

 

TinyPortal © 2005-2018