Android Question Firebase Push Notification - integration with ASP.NET

Alex_197

Well-Known Member
Licensed User
Longtime User
Hi all.

I want to integrate the Firebase Push Notification with my asp,net website. But from what I read so far is that the token generated by B4J GetTokenValue is valid for 1 hour only.
So if I start B4J sending tool and copy the token string from there and use it in my asp.net this token will expire in 1 hour.

Is there any options to either convert GetTokenValue to vb.net /c# or to pass some parameters into B4J project?
 

DonManfred

Expert
Licensed User
Longtime User
or to pass some parameters into B4J project?

The given parameters are in Args.

B4X:
Sub AppStart (Form1 As Form, Args() As String)
...
End sub

I can´t help you with code in vb.net /c# to start an app and give parameters.

In Delphi i use

B4X:
    OpenProgram2('"C:\Java\jdk-11.0.1\bin\javaw.exe"',tempdir,'--module-path C:\Java\jdk-11.0.1\javafx\lib --add-modules ALL-MODULE-PATH -jar \\192.168.2.252\jars\UnternehmerErklaerung.jar '+IntToStr(abnr)+'');
where IntToStr(abnr) is ust the string-interpretion of abnr (int).

You can add more parameters.

OpenProgram2 is just a helper-sub around ShellExecute

B4X:
procedure OpenProgram2(prog, path, params: string);
var
  c, p, dir: array[0..800] of Char;
begin
  StrPCopy(c, prog);
  StrPCopy(p, params);
  StrPCopy(dir, path);
  ShellExecute(0, 'open', c, p, dir, SW_NORMAL);
end;
 
Last edited:
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
The given parameters are in Args.

B4X:
Sub AppStart (Form1 As Form, Args() As String)
...
End sub

I can´t help you with code in vb.net /c# to start an app and give parameters.

In Delphi i use

B4X:
    OpenProgram2('"C:\Java\jdk-11.0.1\bin\javaw.exe"',tempdir,'--module-path C:\Java\jdk-11.0.1\javafx\lib --add-modules ALL-MODULE-PATH -jar \\192.168.2.252\jars\UnternehmerErklaerung.jar '+IntToStr(abnr)+'');
where IntToStr(abnr) is ust the string-interpretion of abnr (int).

You can add more parameters.

OpenProgram2 is just a helper-sub around ShellExecute

B4X:
procedure OpenProgram2(prog, path, params: string);
var
  c, p, dir: array[0..800] of Char;
begin
  StrPCopy(c, prog);
  StrPCopy(p, params);
  StrPCopy(dir, path);
  ShellExecute(0, 'open', c, p, dir, SW_NORMAL);
end;
Thanks, That's what I need.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
What exactly do you mean?
I'm asking - is it possible to convert into C# or VB/NET this code

B4X:
Private Sub GetTokenValue (FilePath As String) As String
    Dim GoogleCredentials As JavaObject
    GoogleCredentials.InitializeStatic("com.google.auth.oauth2.GoogleCredentials")
    Dim Credentials As JavaObject = GoogleCredentials.RunMethodJO("fromStream", Array(File.OpenInput(FilePath, ""))) _
        .RunMethod("createScoped", Array(Array As String("https://www.googleapis.com/auth/firebase.messaging")))
    Credentials.RunMethod("refreshIfExpired", Null)
    Return Credentials.RunMethodJO("getAccessToken", Null).RunMethod("getTokenValue", Null)
End Sub

I need to send messages from my asp.net website.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
I guess that it is possible. You need to go over Google documentation and find whether they provide asp.net SDK and follow their instructions.
Thank you. I will check it, But what if they don't have asp.net SDK?
 
Upvote 0
Top