Skip to content

setAppId not setting OneSignal credentials. #532

@elhe26

Description

@elhe26

Description:
OneSignal.shared.getDeviceState() is returning null values after setting appId:

{
  "hasNotificationPermission": true,
  "isPushDisabled": false,
  "isSubscribed": false,
  "userId": null,
  "pushToken": null,
   "isEmailSubscribed": false,
  "emailUserId": null,
  "emailAddress": null,
  "isSMSSubscribed": false,
  "smsUserId": null,
  "smsNumber": null,
  "notificationPermissionStatus": null
 }

(your description here)

Environment

  1. What version of the OneSignal Flutter SDK are you using? 3.2.7
  2. How did you add the SDK to your project (eg. pub) pubspec.yaml

Steps to Reproduce Issue:

  1. Install the OneSignal Flutter SDK using pub into your project - Done
  2. Initialize the SDK using OneSignal.shared.setAppId(your_app_id) - Done
  3. Attempt to receive push notification - I sent a notification from the admin console. It didn't receive the notification.

Implementation:

Future<void> init() async {
  OneSignal.shared.setLogLevel(OSLogLevel.verbose, OSLogLevel.none);

  OneSignal.shared.setRequiresUserPrivacyConsent(_requiredConsent);

    OneSignal.shared.setNotificationWillShowInForegroundHandler(
        (OSNotificationReceivedEvent event) {
      event.complete(null);
    });

   OneSignal.shared.setNotificationOpenedHandler(...);

   await OneSignal.shared.setAppId(ConfigReader.getOneSignalKey);

   await OneSignal.shared.consentGranted(_consent);
}

Anything else:

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

E/OneSignal(13302): Cannot change requiresUserPrivacyConsent() from TRUE to FALSE
E/OneSignal(13302): promptPermission() is not applicable in Android
...
V/OneSignal(13302): Initializing the OneSignal Flutter SDK (3.2.7)
...
D/OneSignal(13302): Adding a task to the pending queue with ID: 1
D/OneSignal(13302): startPendingTasks with task queue quantity: 1
D/OneSignal(13302): Attempted to clean 6 month old IAM data, but none exists!
D/OneSignal(13302): Retrieved IAMs from DB redisplayedInAppMessages: []
I/OneSignal(13302): Last Pending Task has ran, shutting down
D/OneSignal(13302): OneSignal InAppMessageTracker initInfluencedTypeFromCache: OSChannelTracker{tag=iam_id, influenceType=UNATTRIBUTED, indirectIds=null, directId=null}
D/OneSignal(13302): OneSignal NotificationTracker initInfluencedTypeFromCache: OSChannelTracker{tag=notification_id, influenceType=UNATTRIBUTED, indirectIds=null, directId=null}
D/OneSignal(13302): OneSignal getUnattributedUniqueOutcomeEventsSentByChannel: null
W/OneSignal(13302): appContext set, but please call setAppId(appId) with a valid appId to complete OneSignal init!
V/OneSignal(13302): setAppId called with id: ONESIGNAL-KEY-ID changing id from: null
V/OneSignal(13302): Starting OneSignal initialization!
V/OneSignal(13302): No class found, not setting up OSRemoteNotificationReceivedHandler
V/OneSignal(13302): OneSignal SDK initialization delayed, waiting for remote params.
D/OneSignal(13302): Starting request to get Android parameters.
D/OneSignal(13302): OneSignalRestClient: Making request to: https://api.onesignal.com/apps/**ONESIGNAL-KEY-ID**/android_params.js
...
W/OneSignal(13302): OneSignalRestClient: null Error thrown from network stack. 
/OneSignal(13302): javax.net.ssl.SSLException: Read error: ssl=0x79cf629d08: I/O error during system call, Connection reset by peer

W/OneSignal(13302): 	at com.onesignal.OneSignalRestClient.startHTTPConnection(OneSignalRestClient.java:197)
W/OneSignal(13302): 	at com.onesignal.OneSignalRestClient.access$100(OneSignalRestClient.java:46)
W/OneSignal(13302): 	at com.onesignal.OneSignalRestClient$4.run(OneSignalRestClient.java:114)

I/OneSignal(13302): Failed to get Android parameters, trying again in 30 seconds.
...

D/OneSignal(13302): Starting request to get Android parameters.
D/OneSignal(13302): OneSignalRestClient: Making request to: https://api.onesignal.com/apps/**ONESIGNAL-KEY-ID**/android_params.js
W/OneSignal(13302): OneSignalRestClient: null Error thrown from network stack. 

...
I/OneSignal(13302): Failed to get Android parameters, trying again in 40 seconds.
...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions