how to initialize wifi settings in a production IOT device
There are Arduino libraries available that start a simple Access Point application with a Captive Portal when the ESP can’t find a local Wifi network to connect to. 

The Captive Portal allows a user to log on to the AP created by the ESP from a different device like a phone or laptop, with a preconfigured Wifi password, open a simple web page, search for a local Wifi network to connect to, and enter its credentials.

Once configured, it will from then on use these SSID / credentials.

The library is called “WifiManager” and there are several varieties (for the ESP8266 and the ESP32).