LuisRodriguezLD / Fuse-Firebase-Notifications

Simple app. Receives notifications from Firebase
MIT License
1 stars 1 forks source link

In Notifications.js #1

Open pasza01 opened 7 years ago

pasza01 commented 7 years ago

In Notifications.js change line 44 with your api key

Which api key should I use. Server key or legacy server key?

I tried both. It doesn't work. Am I missing something?

LuisRodriguezLD commented 7 years ago

Hello, I use the Legacy key. Please note that it must have key= before the actual key. Eg. 'Authorization' : 'key=000000000000000000000000000000000000000'

Also, just a reminder: This is for testing only, if you want to use this on a Release build you will need a couple of changes. https://github.com/LuisRodriguezLD/Fuse-Firebase-Notifications#important-ios

pasza01 commented 7 years ago

Did the legacy server. Enable push on xcode still no success. Sandbox is true, because i am testing internally. for certificate, I uploaded .p8 certificate. A lot of certificate don't know which one to use.

LuisRodriguezLD commented 7 years ago

Ah, apparently Firebase edited some of the documentation. And it now prefers Keys rather than certificates. I will update this repo soon but it still works, just follow this steps. The certificate you need is a .p12 file.

1) Create a Push Notification certificate from the Developer page (https://developer.apple.com/account/ios/certificate/create)

2) Select Apple Push Notification service SSL (Sandbox & Production)

3) Choose your App Id (This must match your Fuse Project)

4) Create a Certificate Signing Request (CSR) (Just follow the instructions on screen)

5) Upload your .CSR file generated in step 4

6) Apple will sign it, download that file. Open it and It will be added to your Keychain.

7) Go to that certificate on Keychain, right click on it and export it. That file will be a .p12 file. Upload to Firebase under Settings - Cloud Messaging; choose your app and select APNs Certificates. Use the same certificate for Development and Production.

Please let me know if you have any additional questions.

pasza01 commented 7 years ago

still not working. followed every steps. Do i have to do anything on xcode?

LuisRodriguezLD commented 7 years ago

This is interesting. Maybe something else changed. Could you please post the console log you get from Xcode?

pasza01 commented 7 years ago

2017-08-15 14:37:24.259468-0500 nsatlm[15211:3021455] [DYMTLInitPlatform] platform initialization successful 2017-08-15 14:37:24.398343-0500 nsatlm[15211:3021280] libMobileGestalt MobileGestaltSupport.m:153: pid 15211 (nsatlm) does not have sandbox access for frZQaeyWLUvLjeuE3hmg and IS NOT appropriately entitled 2017-08-15 14:37:24.398486-0500 nsatlm[15211:3021280] libMobileGestalt MobileGestalt.c:550: no access to InverseDeviceID (see rdar://problem/11744455)

LuisRodriguezLD commented 7 years ago

This not an issue with the repo nor Fuse. Apparently there is a huge thread regarding that specific issue -> https://forums.developer.apple.com/thread/72286

Probably related to certificates or signing. To be honest I don't know but you could try:

1) In Xcode, go to settings, accounts and download all profiles 2) Clean Xcode, cmd + shit + k 3) Close Xcode 4) In Fuse, uno clean and rebuild

Again, not sure what causes it and apparently a lot of users are seeing it. Sorry I can't help much on that area. Send me PM on Fuse's slack, I can give you a hand there.

I'll keep this open until I update it to use Keys instead of Certificates.

pasza01 commented 7 years ago

Finally, it works. But notification doesn't show up in notification bar. only shows text after running

LuisRodriguezLD commented 7 years ago

I'm glad it worked. Could you share your solution for future problems? About the notification, it will only reach the notification center if the app is out of focus. If the app is open the notification will be delivered in a JSON format, then you can create your own notification.

More on that: https://www.fusetools.com/docs/fuse/pushnotifications/push#the-notification

pasza01 commented 7 years ago

my bad it not working. Works for device with device token only. I tested with NWPusher which was on fusetools docs. I think the APNtoFCM() never runs. Sorry for the confusion

pasza01 commented 7 years ago

I am confused with this fetch

fetch("https://iid.googleapis.com/iid/v1:batchImport", options) .then(function(response) { return response.json();

Don't we have to add device token before importing? or I am completely lost

pasza01 commented 7 years ago

I keep getting invalid fcm token even though the above code you provided print out long string of FCM token.

LuisRodriguezLD commented 7 years ago

Sorry for the delay. That fetch transforms the Apple Push Notification token and transforms it into Google Cloud messaging token.

Here is more info on that API -> https://developers.google.com/instance-id/reference/server#create_registration_tokens_for_apns_tokens

You can also take a look at the very bottom on that page, there are errors and their definitions.

pasza01 commented 7 years ago

Hi, Thanks for the info. Is there a way you could run this project again and confirm it still works or not on firebase. If this work for you. I will be sure I messed up somewhere and will work into it. Please

LuisRodriguezLD commented 7 years ago

Interesting, I can't get it to work either. Changing this to bug, I will check what's going on. It was working, maybe Firebase changed something (?).

Or maybe I missed something..?