Shielding .all(except: ) unexpected behavior

Hi everyone,

I’m encountering an issue with shield.applicationCategories = .all(except: applications.applicationTokens) when trying to shield all apps except a specified few. Despite using this configuration, all apps are getting shielded, including those that should be exempt.

I’ve verified that the correct applicationTokens are being used and ensured that there are no conflicting schedules that might override this configuration. Interestingly, the ShieldConfiguration appears for the apps that are supposed to be blocked, but not for the ones in the exception list.

Has anyone else experienced this issue, or does anyone have insights into what might be causing this behavior?

Thanks in advance!

Answered by Maximillian-Dev in 804841022

I have been able to solve this issue. It may vary for you, but mostly it will result to some value to be unexpectedly nil inside the ShieldConfiguration.

TLDR

You need to make sure that when overriding the ShieldConfiguration for Category (Application and Web) you don't use the WebDomainToken or ApplicationToken, but instead the CategoryToken. Any other token will result to nil (I think), which causes the ShieldConfiguration to crash and show the default screen.

If this isn't your issue, maybe some other value will result to nil and cause your Configuration to crash.

Here are the details:

I have a function to create a ShieldConfiguration, which takes a token (the underlying Application, WebDomain or CategoryToken). I have created an enum for the tokens as following:

public enum ShieldToken {
  case applicationToken(ApplicationToken)
  case webDomainToken(WebDomainToken)
  case categoryToken(ActivityCategoryToken)
}

Now inside the ShieldConfiguration when overriding the shielding for categories the issue was:

 override func configuration(shielding application: Application, in category: ActivityCategory) -> ShieldConfiguration {
    return customShieldConfiguration(
token: .applicationToken(application.token!), // this was the issue: using the applicationToken when overriding the function for the category. Instead use .categoryToken(category.token!) 
displayName: application.localizedDisplayName)
  }

I’m seeing the very same issue right now (iOS 18.1 beta 4). Have you been able to figure out what’s going on?

For me, the exempted apps show the default shield configuration "App Restricted" even though no shield should be shown at all.

Feedback Report filed under FB15190710

Accepted Answer

I have been able to solve this issue. It may vary for you, but mostly it will result to some value to be unexpectedly nil inside the ShieldConfiguration.

TLDR

You need to make sure that when overriding the ShieldConfiguration for Category (Application and Web) you don't use the WebDomainToken or ApplicationToken, but instead the CategoryToken. Any other token will result to nil (I think), which causes the ShieldConfiguration to crash and show the default screen.

If this isn't your issue, maybe some other value will result to nil and cause your Configuration to crash.

Here are the details:

I have a function to create a ShieldConfiguration, which takes a token (the underlying Application, WebDomain or CategoryToken). I have created an enum for the tokens as following:

public enum ShieldToken {
  case applicationToken(ApplicationToken)
  case webDomainToken(WebDomainToken)
  case categoryToken(ActivityCategoryToken)
}

Now inside the ShieldConfiguration when overriding the shielding for categories the issue was:

 override func configuration(shielding application: Application, in category: ActivityCategory) -> ShieldConfiguration {
    return customShieldConfiguration(
token: .applicationToken(application.token!), // this was the issue: using the applicationToken when overriding the function for the category. Instead use .categoryToken(category.token!) 
displayName: application.localizedDisplayName)
  }
Shielding .all(except: ) unexpected behavior
 
 
Q