B4J Question Error occurred For [B4X] Firebase Push Notifications 2023+ B4j Sending tools

Status
Not open for further replies.

Mehrzad238

Member
after two years I was back in programming and a lot of things had been changed mostly FCM notification, so tried to work with your example and I was faced with that error and I have no idea how to fix this or what it wants
help me understand how to send notifications in B4J and B4A

Thanks in advance

Example link

error message:
B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 71 (Main)
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
    at anywheresoftware.b4j.object.JavaObject.RunMethodJO(JavaObject.java:139)
    at b4j.example.main._gettokenvalue(main.java:154)
    at b4j.example.main$ResumableSub_Send.resume(main.java:105)
    at b4j.example.main._send(main.java:76)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at b4j.example.main.main(main.java:29)
Caused by: java.io.IOException: Error reading credentials from stream, 'type' field not specified.
    at com.google.auth.oauth2.GoogleCredentials.fromStream(GoogleCredentials.java:170)
    at com.google.auth.oauth2.GoogleCredentials.fromStream(GoogleCredentials.java:143)
    ... 24 more

the line that gives m this error
B4X:
Dim Credentials As JavaObject = GoogleCredentials.RunMethodJO("fromStream", Array(File.OpenInput(FilePath, ""))).RunMethod("createScoped", Array(Array As String("https://www.googleapis.com/auth/firebase.messaging")))
 

Mehrzad238

Member
JSON file has been created by this tutorial

https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/

and of course this one
https://www.b4x.com/android/forum/threads/b4x-firebase-push-notifications-2023.148715/

plus this isn't my first time using Firebase messaging it just Google changed it and the last method was This is not working anymore then I had to create a new JSON following your tutorial, which includes these parts

XML:
{
  "project_info": {
    "project_number": "92*********817",
    "project_id": "myapp1",
    "storage_bucket": "myapp1.appspot.com"
  },
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "1:92*********817:android:6c67************c4408",
        "android_client_info": {
          "package_name": "com.myapp1.app"
        }
      },
      "oauth_client": [
        {
          "client_id": "92********817-93t*****************p6jg.apps.googleusercontent.com",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "AIza*********************************zUU"
        }
      ],
      "services": {
        "appinvite_service": {
          "other_platform_oauth_client": [
            {
              "client_id": "92********817-93t*****************p6jg.apps.googleusercontent.com",
              "client_type": 3
            }
          ]
        }
      }
    }
  ],
  "configuration_version": "1"
}

I want to know part of this line code that says file patch and then it's an empty part like
B4X:
" "
what should be in it?

File.OpenInput(FilePath, ""))

and last question is there any JSON other than this google-services.json?
 
Upvote 0
Status
Not open for further replies.
Top