OneSignal / react-native-onesignal

React Native Library for OneSignal Push Notifications Service
Other
1.57k stars 373 forks source link

FATAL: OneSignal AppId: (null) - AppId is null or format is invalid, stopping initialization. Example usage: 'b2f7f966-d8cc-11e4-bed1-df8f05be55ba' #1598

Open ashwinThomas04 opened 11 months ago

ashwinThomas04 commented 11 months ago

What happened?

Recently updated to 5.0.2 to 4.4.1 and made the necessary migration changes. But facing this issue everytime I build the app. The app seems to be stuck with only this in the log. Its working fine for android. Is there something I missed during migration.

Steps to reproduce?

1. Update the app and make migration changes
2. Run app

What did you expect to happen?

I expected the app to not crash.

React Native OneSignal SDK version

5.0.2

Which platform(s) are affected?

Relevant log output

2023-11-07 16:39:28.318537+0530 ExampleApp[6472:679857] [User Defaults] Couldn't read values in CFPrefsPlistSource<0x281521800> (Domain: group.com.exampleapp.onesignal, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd
2023-11-07 16:39:28.451268+0530 ExampleApp[6472:679857] FATAL: OneSignal AppId: (null) - AppId is null or format is invalid, stopping initialization.
Example usage: 'b2f7f966-d8cc-11e4-bed1-df8f05be55ba'
2023-11-07 16:39:28.595439+0530 ExampleApp[6472:680153] 10.17.0 - [FirebaseAnalytics][I-ACS023007] Analytics v.10.17.0 started
2023-11-07 16:39:28.601875+0530 ExampleApp[6472:680153] 10.17.0 - [FirebaseAnalytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2023-11-07 16:39:28.608521+0530 ExampleApp[6472:679857] [ViewportSizing] maximumViewportInset cannot be larger than frame
2023-11-07 16:39:28.608592+0530 ExampleApp[6472:679857] [ViewportSizing] minimumViewportInset cannot be larger than frame
2023-11-07 16:39:28.800779+0530 ExampleApp[6472:680169] 10.17.0 - [FirebaseAnalytics][I-ACS044002] The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at http://goo.gl/9vSsPb
2023-11-07 16:39:29.365164+0530 ExampleApp[6472:680153] 10.17.0 - [FirebaseAnalytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2023-11-07 16:39:29.513928+0530 ExampleApp[6472:680162] 10.17.0 - [FirebaseAnalytics][I-ACS023012] Analytics collection enabled
2023-11-07 16:39:29.514228+0530 ExampleApp[6472:680162] 10.17.0 - [FirebaseAnalytics][I-ACS023220] Analytics screen reporting is enabled. Call Analytics.logEvent(AnalyticsEventScreenView, parameters: [...]) to log a screen view event. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO (boolean) in the Info.plist
2023-11-07 16:43:29.542223+0530 ExampleApp[6472:680247] [tcp] tcp_input [C2.1.1:3] flags=[R] seq=2977095748, ack=0, win=0 state=TIME_WAIT rcv_nxt=2977095748, snd_una=1073989792

Code of Conduct

ashwinThomas04 commented 11 months ago

The app is working fine in android without any build errors. I'm facing this issue when I try to build app for IOS.

jennantilla commented 11 months ago

Hi @ashwinThomas04 thank you for your patience. Are you still having this issue? If so would you be able to share the initialization code you used?

ashwinThomas04 commented 11 months ago

Hi @jennantilla , I reverted back to previous react-native version as I was still facing the issue.

useEffect(( )=>{
    const initializeOnesignal=( )=>{
         OneSignal.Debug.setLogLevel(LogLevel.Verbose);
         OneSignal.initialize(ONE_SIGNAL_ID);
    }

    initializeOnesignal( );
},[]);

This is the initialization code. I tried removing all instances of Onesignal from the js code and run the app in the latest version, but the error was coming up again in IOS.

ashwinThomas04 commented 10 months ago

@jennantilla , this error came up when I migrated from 4.4.1 to 5.0.2, as a part of updating the app. I followed the migration guides and believe I made the necessary changes. The app was working fine in android and there was no issue in receiving notifications either. But when I tried building for IOS, the app was getting stuck at the splash screen after the build succeeded message. This was the only error I could find in the metro console. I rechecked the onesignal documentation a few times, but I'm not sure if I missed out anything during the migration process.

SamiChab commented 10 months ago

I had exactly the same problem on version 5.0.3. Switching back to version 4.5.2 solved it: the error disappeared

codingwithashu commented 10 months ago

Same issue in ionic Cordova

Screenshot 2023-12-02 at 7 44 42 PM
v12cicd commented 10 months ago

same issue in cordova 12.0.0

source 'https://cdn.cocoapods.org/'
platform :ios, '11.0'
use_frameworks!
target 'myproject' do
    project 'myproject.xcodeproj'
    pod 'OneSignalXCFramework', '5.0.4'
end
target 'OneSignalNotificationServiceExtension' do
    pod 'OneSignalXCFramework', '5.0.4'
end

FATAL: OneSignal AppId: (null) - AppId is null or format is invalid, stopping

daveaki commented 8 months ago

Hi I have updated the whole application to Cordova 12. Added the Onesignal plugin and got the same error when I started the Iphone 15 emulator. I solved it by adding a setTimeout.

document.addEventListener('deviceready', OneSignalInit, false);
function OneSignalInit() 
{
                setTimeout(() => 
                {
                        window.plugins.OneSignal.initialize("MY_ID");

                        const listener = (event) =>
                        {
                                        const notificationData = JSON.stringify(event);
                                        //redirect alla pagina delle notifiche;
                        };
                        window.plugins.OneSignal.Notifications.addEventListener("click", listener);

                },1000);
}

in One signal Subscriptions I have the Subscription ID => Simulator Iphone 17.0.1

EinfachHans commented 6 months ago

Same error happened today for me with latest Capacitor version. Adding a small timeout seems to fix it - can someone look into it?

Mytrailpals commented 4 months ago

Facing the same issue, while running the app in Xcode. Anyone able to resolve it?

FATAL: OneSignal AppId: (null) - AppId is null or format is invalid, stopping initialization. Example usage: 'b2f7f966-d8cc-11e4-bed1-df8f05be55ba'

kevshub commented 2 months ago

Facing the same issue with a brand new installation of cordova, with only the onesignal plugin and the basic helloworld demo app. The onesignal plugin spits out this error :FATAL: OneSignal AppId: (null) even before the deviceready function is called.

nan-li commented 2 months ago

Hi everyone, since you are using one of our cross-platform SDKs, this is a misleading error message that prints from the integration of our cross platform SDK with our native iOS SDK.

Please check your logs to see if the following prints after the FATAL log, that the App ID is successfully set, so you can safely ignore the error log.

VERBOSE: setAppId called with appId: abcd-1234-abcd-1234
VERBOSE: launchOptions is set and appId of abcd-1234-abcd-1234 is set, initializing OneSignal...

This is an alarming error log and misleading, we will work on suppressing or rewording the log.

kevshub commented 2 months ago

I've reverted to version 3.3.1 and the error has been resolved.

I can confirm that the above is not printed after the fatal error. Heres a copy of my log before i reverted back to v3.3.1

Apache Cordova iOS platform version 7.1.1 is starting. FATAL: OneSignal AppId: (null) - AppId is null or format is invalid, stopping initialization. Example usage: 'b2f7f966-d8cc-11e4-bed1-df8f05be55ba' Warning: -[BETextInput attributedMarkedText] is unimplemented CDVWebViewEngine will reload WKWebView if required on resume Using WKWebView [CDVTimer][console] 0.059009ms [CDVTimer][handleopenurl] 0.018001ms [CDVTimer][intentandnavigationfilter] 1.026034ms [CDVTimer][gesturehandler] 0.066042ms [CDVTimer][TotalPluginStartup] 1.471996ms nw_application_id_create_self NECP_CLIENT_ACTION_GET_SIGNED_CLIENT_ID [80: Authentication error] Failed to resolve host network app id The preference key "AutoHideSplashScreen" is not defined and will default to "TRUE"

Its worth noting that onesignal is not initializing and the functions are not available to the app. for example when i try to call the log function:

window.plugins.OneSignal.setLogLevel is not a function. (In 'window.plugins.OneSignal.setLogLevel(6, 0)', 'window.plugins.OneSignal.setLogLevel' is undefined)

The error everyone is describing is occurring BEFORE the deviceready function.

Also - specifically for me I'm using onesignal-cordova-plugin rather than react-native-onesignal but the error is exactly the same which is why i posted here