Custom mobile app and implement Push notify

Theerayuttua month ago

Hi,
We have custom mobile app from traccar-manager-app iOS & Android and need to implement Push notify also
we have create Firebase project and download google-services.json into Android project and GoogleService-Info.plist into Xcode project

for Android to add plugins and dependencies in build.gradle file
Screenshot 2025-02-18 143316.png

for Xcode after put GoogleService-Info.plist and then to enable this script on AppDelegate.swift right?
Screenshot 2568-02-18 at 14.14.35.png

Is this all we need to do? can we start build the project right away?

Theerayuttua month ago

Android first, already put google-services.json and selected build variant is googleDebug

it build failed

Screenshot 2025-02-22 204638.png

Compilation error:

> Task :app:compileGoogleDebugKotlin FAILED
e: file:///C:/Users/user/.gradle/caches/transforms-3/06a85c92cb14c9b90e73303ac62102ec/transformed/play-services-measurement-api-22.2.0-api.jar!/META-INF/java.com.google.android.gmscore.integ.client.measurement_api_measurement_api.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.9.0.
e: file:///C:/Users/user/.gradle/caches/transforms-3/764584a5dcaa928172e95dfbe0ffdd27/transformed/play-services-measurement-impl-22.2.0-api.jar!/META-INF/java.com.google.android.gms.libs.filecompliance.proto_file_access_api_type_kt_proto_lite.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.9.0.
e: file:///C:/Users/user/.gradle/caches/transforms-3/764584a5dcaa928172e95dfbe0ffdd27/transformed/play-services-measurement-impl-22.2.0-api.jar!/META-INF/third_party.kotlin.protobuf.src.commonMain.kotlin.com.google.protobuf.kotlin_only_for_use_in_proto_generated_code_its_generator_and_tests.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.9.0.
e: file:///C:/Users/user/.gradle/caches/transforms-3/764584a5dcaa928172e95dfbe0ffdd27/transformed/play-services-measurement-impl-22.2.0-api.jar!/META-INF/third_party.kotlin.protobuf.src.commonMain.kotlin.com.google.protobuf.kotlin_shared_runtime.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.9.0.

not sure, it wrong any dependencies version in build.gradle or am I doing something wrong?

Please help advice. Thank you.

Theerayuttua month ago

investigation and finding information and gpt help.
now Build passed and run with notify to work.

from build error: kotlin incompatible version: (The binary version of its metadata is 2.1.0, expected version is 1.9.0.)
fixed to change kotlin version in build.gradle file of project from 1.9.0 to version 2.1.0

Screenshot 2025-02-23 081345.png

select build variant googleDebug

Screenshot 2025-02-23 081727.png

Theerayuttua month ago

Rebuild Project again and try to run app on Emulator
Screenshot 2025-02-23 081931.png

Test send Notify from web app

Screenshot 2025-02-23 082531.png

Theerayuttua month ago

Next Xcode for iOS. I will try to do and share again.
thanks.

Theerayuttua month ago

For iOS app
we have created iOS app in Firebase project

Screenshot 2025-02-24 121815.png

and created APNs key

Screenshot 2025-02-24 121925.png

in Xcode project we have put GoogleService-Info.plist file in project and edit script in AppDelegate to comment code #if FIREBASE

Screenshot 2568-02-24 at 12.11.09.png

Theerayuttua month ago

start run (Simulator) app alert to Allow Notify
Screenshot 2025-02-24 130936.png

We already allowed Notify and then send Test Message on web app, for Android devices it works, received a notify, but iOS still doesn't work. no any notify in device.

Not sure if I did something wrong?

Theerayuttua month ago

Look at log file. found response error when send notify.

WARN: Firebase user 8 error - 401 Unauthorized
POST https://fcm.googleapis.com/v1/projects/marstian-XXXXf/messages:send
{
  "error": {
    "code": 401,
    "message": "Auth error from APNS or Web Push Service",
    "status": "UNAUTHENTICATED",
    "details": [
      {
        "@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
        "errorCode": "THIRD_PARTY_AUTH_ERROR"
      },
      {
        "@type": "type.googleapis.com/google.firebase.fcm.v1.ApnsError",
        "statusCode": 403,
        "reason": "InvalidProviderToken"
      }
    ]
  }
}
 - HttpResponseException (...)
Theerayuttua month ago

Has anyone ever encountered an error like this? Please give me some advice.

Anton Tananaeva month ago

Have you uploaded your APNs key to the Firebase project?

Theerayuttua month ago

Hello Anton,
yes, we already uploaded .p8 file into Firebase iOS app

Screenshot 2025-02-25 061132.png

uploaded to Firebase iOS app
Screenshot 2025-02-25 061959.png

Theerayuttua month ago

rechecked, the keys are all matched.

Theerayuttua month ago

try again, but still don't work.

Theerayuttua month ago

Hi,
After several days of trying, now was finally able to send a notification to iOS and Android custom app.

image (4).png

to fixed this case error - 401 Unauthorized when Firebase send notify to Apple push notification service. (APNs)
We tried generating a new APNs key and revoke the previous key in Apple developer account and then delete and upload new APNs Key in Firebase cloud messaging again.