customerio / customerio-expo-plugin

MIT License
12 stars 9 forks source link

How does the Push Enabled Push Disabled work ? #136

Closed Samox closed 5 months ago

Samox commented 5 months ago

Hello ! I'm not sure this question belongs here but I con't find documentation on that. I do not understand how the Push Enable & Push Disable is set on customerio. I have 80% of my users with device that are Push Disabled, trying to understand why.

I have a device with the installed app, and its said I have Push Disabled, but I did not do anything on the phone. If I send push notif, it works well.

CleanShot 2024-04-05 at 18 10 59@2x

Also I did another test with an iphone. Installed, uninstalled and reinstalled. That makes 2 device token (that I understand). Why is the first one Enabled, and the second (newer) one Disable. (I see a weird SDK version as well, it was from the same build I swear, might be an expo version vs RN version)

CleanShot 2024-04-05 at 18 15 49@2x

Thanks 😇

ami-aman commented 5 months ago

Hi @Samox

Apologies for the inconvenience.

Our SDK automatically collects device attributes during device registration. This feature is enabled by default and captures information like platform, version, push_enabled etc.

However, in iOS push notification permission requires explicit user consent (it's off by default), there might be a lag in getting the actual push_enabled value.

Initially, when the device registers (typically at app launch, and assuming it is first time app launch), the SDK fetches device attributes, and push_enabled will likely be false because push permission hasn't been requested yet. Later, when your app requests for push authorization and the user grants permission, the push_enabled status will be updated, but only on the next app launch or when device attributes are refreshed.

This is why you see that the first app you installed initially had disabled but later enabled and the second one as disabled as I assume that you did not relaunch the app.

I realise that the docs do not mention any of the points that I just highlighted. I am adding a note internally to talk about this with our docs team. Thanks for your question.

Samox commented 5 months ago

Oh ok I think I get it. Thanks !

Samox commented 5 months ago

@ami-aman I tried to force a refresh of the device after the user's permission, but if I understand correctly, the app must be restarted in order to have the right "push enabled" value in the sdk right ? Just want to make sure there is no other way to get the data right at first launch :D .

Also I see this update on my users. Is there a way to prevent it ? It is kind of noisy

cio_sdk_version: {
from: "1.0.0-beta.15"
to: "2.12.3"
}

CleanShot 2024-04-11 at 12 17 59@2x

levibostian commented 5 months ago

Sammy, instead of forcing your app to restart, you can re-register the device like this:

    // After your user accepts push permission, call this code: 
   let token = await CustomerIO.pushMessaging().getRegisteredDeviceToken()
   if (token) {
      CustomerIO.registerDeviceToken(token)
   }

This will fetch the latest value for push_enabled and send that to Customer.io. No need to restart your app or anything.

Also I see this update on my users. Is there a way to prevent it ? It is kind of noisy

Sorry for this noise. I have documented this internally for us to look into. Unfortunately, I am not able to provide a date you can expect to see this improved.