customerio / customerio-flutter

Flutter plugin for Customer.io
https://www.customer.io/docs/sdk/flutter/getting-started/
MIT License
12 stars 10 forks source link

What to pick as a token when manually adding device to profile? #96

Closed antonengelhardt closed 8 months ago

antonengelhardt commented 8 months ago

Hello, i am trying to connect a device to a user with Flutter. What do i pick as a token for the registration process? Your docs suggest that it is possible to add devices manually, but i only see APNs 400 BadDeviceToken: Device token is invalid or doesn't work with this platform. Register a corrected token. when i test the implementation. I tried it with user ids, random numbers.

On a side note: the manual registration is required because for some reason, the device is not automatically added...

Thanks !

Shahroz16 commented 8 months ago

Hey @antonengelhardt, thank you for reaching out. I am not sure I follow the question, so can you give a bit more detail?

You can add the token manually by using CustomerIO.registerDeviceToken(token). The token needs to be a valid FCM token, it's going to be different for Android and iOS.

I see you are using APN but I am not sure, how you are creating the token and trying to register it manually.

antonengelhardt commented 8 months ago

@Shahroz16 We need to deliver Push notifications to iOS and Android, so we are looking for the easiest way to achieve this.

Now i am manually adding the devices to the profile and the devices are shown there. But i am unsure where do get the FCM token from? How do i get it so that i can call registerDeviceToken()?

Should i use FCM for iOS and Android or APN for iOS and FCM for Android? How do i get the token if i do each platform separately?

Shahroz16 commented 8 months ago

@antonengelhardt, the easiest way to set push notifications would be to follow docs and let the SDKs add the token automatically for you.

If you still want to add it manually, you can use Flutter Fire FCM messaging to get the token and provide it to the CustomerIO

antonengelhardt commented 8 months ago

@Shahroz16 I have followed the docs, but my device was never added automatically. So we did it manually.

With Flutterfire, we are able to get the token now. But when i test the token, i get an error for APN:

Screenshot-Google Chrome-004433

FCM is at least sending the test but it never arrives, although my the value of push_enabledis true:

Screenshot-Google Chrome-004435

Screenshot-Google Chrome-004437

Shahroz16 commented 8 months ago

@antonengelhardt Flutter fire also uses FCM.

APN won't work out of the box with the SDK.

Can you please recheck your FCM integration? Did you add the google-services.json file in android and similarly the corresponding one for iOS?

antonengelhardt commented 8 months ago

@Shahroz16 Thanks for your support.

It was indeed a misconfigured Flutterfire. We have two targets: "Runner" & "Production" and the Test Push notifications where sent to the wrong app. I just got the first message.

antonengelhardt commented 8 months ago

@Shahroz16 May i suggest to maybe explain this a little more in the docs? That would have helped me a lot.