Closed skanel closed 6 years ago
Yes they are the same value. But don't copy my id it will not work. Use your own id.
The blog post shows you where you find it in the Firebase Console.
Just realised there is no gcm_sender_id
in sw.js.
I guess you mean messagingSenderId
messagingSenderId
in sw.js and index.js are the same value
If you mean the gcm_sender_id
in the manifest.json file, then it has to be 103953800507
This is a completely different number. See my blog post
Don't change the number 103953800507. This is a fixed number and all clients in the world, that are connected to FCM, use this same number.
{ "gcm_sender_id": "103953800507", }
yes , I know how to create the sender_id, even I put
{
"gcm_sender_id": "103953800507",
}
and test with many option i still get the same error , could you check your repos again?
Thank all of your response time.
how to put this file , is path like this?
fcm.service-account-file=C:\Users\Administrator\Documents\Projects\blog\sw-push\src\main\resources\qm-tracker-backend-firebase-adminsdk-wowh8-d8b0c278a7.json
I tested it on my computer and it works. I updated the version on GitHub (Only upgraded the firebase library to 6.2.0)
My settings looks like this
fcm.service-account-file=D:/ws/blog/sw-push/pushdemo-91541-firebase-adminsdk-sltyt-65f32cb28a.json
Maybe try / instead of \
almost run now but get this
Sending chuck joke... 2018-06-11 16:33:18.284 ERROR 4812 --- [pool-1-thread-1] o.s.s.s.TaskUtils$LoggingErrorHandler : Unexpected error occurred in scheduled task.
java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist. at com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:169) ~[firebase-admin-5.10.0.jar:na] at com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:140) ~[firebase-admin-5.10.0.jar:na] at com.google.firebase.messaging.FirebaseMessaging.getInstance(FirebaseMessaging.java:121) ~[firebase-admin-5.10.0.jar:na] at ch.rasc.swpush.fcm.FcmClient.send(FcmClient.java:52) ~[classes/:na] at ch.rasc.swpush.PushChuckJokeService.sendPushMessage(PushChuckJokeService.java:47) ~[classes/:na] at ch.rasc.swpush.PushChuckJokeService.sendChuckQuotes(PushChuckJokeService.java:32) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171] at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_171] at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_171] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_171] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_171] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_171] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_171] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]
Sending chuck joke... 2018-06-11 16:33:48.761 ERROR 4812 --- [pool-1-thread-1] o.s.s.s.TaskUtils$LoggingErrorHandler : Unexpected error occurred in scheduled task.
java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist. at com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:169) ~[firebase-admin-5.10.0.jar:na] at com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:140) ~[firebase-admin-5.10.0.jar:na] at com.google.firebase.messaging.FirebaseMessaging.getInstance(FirebaseMessaging.java:121) ~[firebase-admin-5.10.0.jar:na] at ch.rasc.swpush.fcm.FcmClient.send(FcmClient.java:52) ~[classes/:na] at ch.rasc.swpush.PushChuckJokeService.sendPushMessage(PushChuckJokeService.java:47) ~[classes/:na] at ch.rasc.swpush.PushChuckJokeService.sendChuckQuotes(PushChuckJokeService.java:32) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171] at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_171] at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_171] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_171] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_171] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_171] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_171] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]
Can you try 6.2.0. That's the version I tested and works on my computer
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>6.2.0</version>
Good now,
=========|_|==============|__/=//// :: Spring Boot :: (v2.0.2.RELEASE)
2018-06-11 16:39:16.420 INFO 3096 --- [lication.main()] ch.rasc.swpush.Application : Starting Application on WIN-5LEI70KI9L7 with PID 3096 (C:\Users\Administrator\Documents\Projects\blog\sw-push\target\classes started by Administrator in C:\Users\Administrator\Documents\Projects\blog\sw-push)
2018-06-11 16:39:16.420 INFO 3096 --- [lication.main()] ch.rasc.swpush.Application : No active profile set, falling back to default profiles: default
2018-06-11 16:39:16.528 INFO 3096 --- [lication.main()] onfigReactiveWebServerApplicationContext : Refreshing org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext@5584c05f: startup date [Mon Jun 11 16:39:16 ICT 2018]; root of context hierarchy
2018-06-11 16:39:19.277 INFO 3096 --- [lication.main()] s.w.r.r.m.a.RequestMappingHandlerMapping : Mapped "{[/register],methods=[POST]}" onto public void ch.rasc.swpush.RegistryController.register(reactor.core.publisher.Mono
java.nio.file.NoSuchFileException: qm-tracker-backend-firebase-adminsdk-wowh8-d8b0c278a7.json
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79) ~[na:1.8.0_171]
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) ~[na:1.8.0_171]
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102) ~[na:1.8.0_171]
at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230) ~[na:1.8.0_171]
at java.nio.file.Files.newByteChannel(Files.java:361) ~[na:1.8.0_171]
at java.nio.file.Files.newByteChannel(Files.java:407) ~[na:1.8.0_171]
at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384) ~[na:1.8.0_171]
at java.nio.file.Files.newInputStream(Files.java:152) ~[na:1.8.0_171]
at ch.rasc.swpush.fcm.FcmClient.
2018-06-11 16:39:25.959 INFO 3096 --- [lication.main()] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 2018-06-11 16:39:26.037 INFO 3096 --- [lication.main()] s.a.ScheduledAnnotationBeanPostProcessor : No TaskScheduler/ScheduledExecutorService bean found for scheduled processing
Here is the error. The file does not exist
java.nio.file.NoSuchFileException: qm-tracker-backend-firebase-adminsdk-wowh8-d8b0c278a7.json
awesome now,
. _ _ /\ / '_ () \ \ \ \ ( ( )\ | ' | '| | ' \/ ` | \ \ \ \ \/ _)| |)| | | | | || (| | ) ) ) ) ' |__| .|| ||| |\, | / / / / =========|_|==============|__/=//// :: Spring Boot :: (v2.0.2.RELEASE)
2018-06-11 16:54:30.481 INFO 5260 --- [ main] ch.rasc.swpush.Application : Starting Application on WIN-5LEI70KI9L7 with PID 5260 (C:\Users\Administrator\Documents\Projects\blog\sw-push\target\classes started by Administrator in C:\Users\Administrator\Documents\Projects\blog\sw-push)
2018-06-11 16:54:30.481 INFO 5260 --- [ main] ch.rasc.swpush.Application : No active profile set, falling back to default profiles: default
2018-06-11 16:54:30.653 INFO 5260 --- [ main] onfigReactiveWebServerApplicationContext : Refreshing org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext@27cd4a7e: startup date [Mon Jun 11 16:54:30 ICT 2018]; root of context hierarchy
2018-06-11 16:54:33.292 INFO 5260 --- [ main] s.w.r.r.m.a.RequestMappingHandlerMapping : Mapped "{[/register],methods=[POST]}" onto public void ch.rasc.swpush.RegistryController.register(reactor.core.publisher.Mono
Looks good. Do you see the messages in the browser?
it works now my hero, thank you so much for you times and your responsibility, I really really appreciate it.
No problem. Happy that I was able to help.
1, gcm_sender_id in sw.js
both are store the save value?