Skip to content

PendingIntent error when targeting Android S (31) #1408

@axiel7

Description

@axiel7

Description:

I'm getting the following error while integrating the OneSignal SDK on a Android project with targetSdk set to 31:
java.lang.IllegalArgumentException: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

Environment

  1. targetSdk and compileSdk set to 31
  2. OneSignal SDK added using the official docs (mavenCentral)

Steps to Reproduce Issue:

  1. Add the OneSignal SDK to a project with targetSdkVersion 31
  2. Initialize OneSignal on the Application class
  3. Compile and launch the app

Anything else:

(crash stacktraces, as well as any other information here)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions