Skip to content

Unable to request consent after initially denying consent

I want to allow users withdraw and grant consent anytime they want. I've added a toggle item in the Settings screen of my app for this purpose. Basically, users can revoke and request consent to a fixed set of campaignIds by toggling that particular setting item.

  • To request consent, I'm calling the requestConsent method of the CleanInsights.kt class.
  • To withdraw consent, I'm calling the deny method of the CleanInsights.kt class and passing the relevant campaignId.

This works for all cases except the case where a user is enabling after disabling. When that happens we get an exception. Here's a sample one:

Already asked for consent for campaign 'test'. It was denied on java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=true,lenient=true,zone=java.util.SimpleTimeZone[id=UTC,offset=0,dstSavings=3600000,useDaylight=false,startYear=0,startMode=0,startMonth=0,startDay=0,startDayOfWeek=0,startTime=0,startTimeMode=0,endMode=0,endMonth=0,endDay=0,endDayOfWeek=0,endTime=0,endTimeMode=0],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2024,MONTH=6,WEEK_OF_YEAR=27,WEEK_OF_MONTH=1,DAY_OF_MONTH=1,DAY_OF_YEAR=183,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=3,HOUR_OF_DAY=15,MINUTE=42,SECOND=51,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0].

The SDK never seems to forget when a permission is revoked and this makes the toggle-implementation a bit tricky. Is there a better way to handle this?

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information