I see this problem came up over several posts with no real answers, so I spent my afternoon figuring out the problem and hopefully this will work for someone else.
I upgraded routers to a new TPLink Archer C4000, and my camera wouldn't connect via wifi. I hard-reset, it has the latest firmware. It would connect with the ethernet cable just fine, but would time out and not connect wirelessly. I happened to notice that the wifi networks were actually grayed out in the app, and started to suspect it was a security issue with my new router. I found that enabling DMZ for the camera IP on the router did the trick.
There's a ton of warnings about doing this and I still have to dig into if this is a huge security hole for some reason, but it worked.
On my router's web interface, there's an Advanced option under NAT forwarding for DMZ (demilitarized zone) enabling. In that area, I input the camera's IP address, reloaded the DLink app, and lo and behold the camera's now allowed to connect to the router wirelessly, and works great.
I know it's an old camera, but I hate the comments that all say "things eventually break, just buy a new one".
If this helps at least one person who doesn't want to toss their old camera, then it's worth it.