OneSignal/OneSignal-Flutter-SDK

[Bug]: OneSignal Initialization with appID doesnt work

simonikook opened this issue · 7 comments

What happened?

The latest version of the Sdk doesn't initialize AppID

Steps to reproduce?

void main() {
  WidgetsFlutterBinding.ensureInitialized();

add this code to main file

void main(){

  runApp(const ProviderScope(child: MyApp()));
  OneSignal.Debug.setLogLevel(OSLogLevel.verbose);

 OneSignal.initialize("f641ba25-a862-4a0f-b518-b8738b13xxxxx");
}


then on user login endpoint add this


OneSignal.login(this.user?.user_id??"");
      OneSignal.User.addEmail(this.user?.email??"");


### What did you expect to happen?

i expect sdk to connect successfully but instead i got error

### OneSignal Flutter SDK version

5.1.4

### Which platform(s) are affected?

- [ ] iOS
- [X] Android

### Relevant log output

```Shell
-3941  OneSignal               com.ikook.ikook                      D  [DefaultDispatcher-worker-1] HttpClient: GET apps/f641ba25-a862-4a0f-b518-b8738b1xxxxx/android_params.js - Using Cached response due to 304: {"awl_list":{},"android_sender_id":"785438383055","chnl_lst":[],"outcomes":{"direct":{"enabled":false},"indirect":{"notification_attribution":{"minutes_since_displayed":60,"limit":10},"enabled":false},"unattributed":{"enabled":false}},"receive_receipts_enable":false}
2024-04-16 10:38:20.189  3836-3836  OneSignal               com.ikook.ikook                      D  [main] login(externalId: 65a8df28304f56f6c95exxx, jwtBearerToken: null)
2024-04-16 10:38:20.189  3836-3836  OneSignal               com.ikook.ikook                      D  [main] addEmail(email: davidoye@xxxx.com)
2024-04-16 10:38:20.190  3836-3836  OneSignal               com.ikook.ikook                      D  [main] SubscriptionManager.addSubscription(type: EMAIL, address: davidoyeka@xxxxx.com)
2024-04-16 10:38:20.199  3836-3836  OneSignal               com.ikook.ikook                      D  [main] OperationRepo.enqueue(operation: {"name":"create-subscription","appId":"f641ba25-a862-4a0f-b518-b87xxxxxxx","onesignalId":"local-001f8ee3-5947-43d5-af47-146a100f3794","subscriptionId":"local-46bb503f-2bbf-4d27-b1cb-db273cec445d","type":"EMAIL","enabled":true,"address":"davidoyekanmi@xxxxx.com","status":"SUBSCRIBED"}, flush: false)
2024-04-16 10:38:24.364  3836-3948  OneSignal               com.ikook.ikook                      D  [OpRepo] processQueueForever:ops:
                                                                                                    [({"name":"login-user","appId":"<YOUR APP ID HERE>","onesignalId":"local-6be1c1f7-3964-4fcd-a040-ff36a26bdd16","id":"06531b25-e2df-4083-942d-2047d69738bc"}, 0)
                                                                                                    , ({"name":"create-subscription","appId":"<YOUR APP ID HERE>","onesignalId":"local-6be1c1f7-3964-4fcd-a040-ff36a26bdd16","subscriptionId":"local-42042c3e-71f5-489f-a388-12e30066b27a","type":"PUSH","enabled":false,"address":"","status":"NO_PERMISSION","id":"b3c42526-3012-405a-8c38-9d80c148dd98"}, 0)
                                                                                                    , ({"name":"update-subscription","appId":"<YOUR APP ID HERE>","onesignalId":"local-6be1c1f7-3964-4fcd-a040-ff36a26bdd16","subscriptionId":"local-42042c3e-71f5-489f-a388-12e30066b27a","type":"PUSH","enabled":false,"address":"","status":"INVALID_FCM_SENDER_ID","id":"249e55fc-ad25-454e-a669-0fc13cc48834"}, 0)
                                                                                                    ]
2024-04-16 10:38:24.367  3836-3948  OneSignal               com.ikook.ikook                      D  [OpRepo] LoginUserOperationExecutor(operation: [{"name":"login-user","appId":"<YOUR APP ID HERE>","onesignalId":"local-6be1c1f7-3964-4fcd-a040-ff36a26bdd16","id":"06531b25-e2df-4083-942d-2047d69738bc"}, {"name":"create-subscription","appId":"<YOUR APP ID HERE>","onesignalId":"local-6be1c1f7-3964-4fcd-a040-ff36a26bdd16","subscriptionId":"local-42042c3e-71f5-489f-a388-12e30066b27a","type":"PUSH","enabled":false,"address":"","status":"NO_PERMISSION","id":"b3c42526-3012-405a-8c38-9d80c148dd98"}, {"name":"update-subscription","appId":"<YOUR APP ID HERE>","onesignalId":"local-6be1c1f7-3964-4fcd-a040-ff36a26bdd16","subscriptionId":"local-42042c3e-71f5-489f-a388-12e30066b27a","type":"PUSH","enabled":false,"address":"","status":"INVALID_FCM_SENDER_ID","id":"249e55fc-ad25-454e-a669-0fc13cc48834"}])
2024-04-16 10:38:24.393  3836-3942  OneSignal               com.ikook.ikook                      D  [DefaultDispatcher-worker-2] HttpClient: POST apps/<YOUR APP ID HERE>/users - {"subscriptions":[{"type":"AndroidPush","token":"","enabled":false,"notification_types":-6,"sdk":"050108","device_model":"SM-G991N","device_os":"14","rooted":false,"net_type":1,"carrier":"MTN Nigeria","app_version":"5"}],"properties":{"timezone_id":"Africa\/Lagos","language":"en"},"refresh_device_metadata":true}
2024-04-16 10:38:24.624  3836-3942  OneSignal               com.ikook.ikook                      D  [DefaultDispatcher-worker-2] HttpClient: POST apps/<YOUR APP ID HERE>/users - FAILED STATUS: 400
2024-04-16 10:38:24.637  3836-3942  OneSignal               com.ikook.ikook                      W  [DefaultDispatcher-worker-2] HttpClient: POST RECEIVED JSON: {"errors":[{"title":"App ID must be a valid UUID"}]}
2024-04-16 10:38:24.639  3836-3948  OneSignal               com.ikook.ikook                      D  [OpRepo] OperationRepo: execute response = FAIL_PAUSE_OPREPO
2024-04-16 10:38:24.643  3836-3948  OneSignal               com.ikook.ikook                      E  Operation execution failed with eventual retry, pausing the operation repo: [{"name":"login-user","appId":"<YOUR APP ID HERE>","onesignalId":"local-6be1c1f7-3964-4fcd-a040-ff36a26bdd16","id":"06531b25-e2df-4083-942d-2047d69738bc"}, {"name":"create-subscription","appId":"<YOUR APP ID HERE>","onesignalId":"local-6be1c1f7-3964-4fcd-a040-ff36a26bdd16","subscriptionId":"local-42042c3e-71f5-489f-a388-12e30066b27a","type":"PUSH","enabled":false,"address":"","status":"NO_PERMISSION","id":"b3c42526-3012-405a-8c38-9d80c148dd98"}, {"name":"update-subscription","appId":"<YOUR APP ID HERE>","onesignalId":"local-6be1c1f7-3964-4fcd-a040-ff36a26bdd16","subscriptionId":"local-42042c3e-71f5-489f-a388-12e30066b27a","type":"PUSH","enabled":false,"address":"","status":"INVALID_FCM_SENDER_ID","id":"249e55fc-ad25-454e-a669-0fc13cc48834"}]

Code of Conduct

  • I agree to follow this project's Code of Conduct

Hi @simonikook,

Can you confirm the <YOUR APP ID HERE> that is in this log, is correct?

HttpClient: POST apps/<YOUR APP ID HERE>/users - FAILED STATUS: 400

@nan-li so as you can see from the code i sent above, i am inputting the app id correctly in main.dart but on log its still showing string from logcat

Ohh ok, I see, you are not redacting your data with <YOUR APP ID HERE>, that is actually the string literal sent.

It looks like in the past, you called OneSignal.initialize("<YOUR APP ID HERE>") in your app, is this correct?
Because of this, there is a cached request that keeps failing.

just install the app and it worked

thanks

For anyone else having this problem, you need to uninstall your app from your device/simulator and then it will work next time