Hello Aleksander,
Thank you for using Apple Support Communities! I understand that not only are you wanting to block all incoming calls and messages from phone numbers not in your contacts, you also do not want to see notifications from the missed calls or messages.
Built-in to iOS is the option to block specific phone numbers, contacts, and emails. You can also filter iMessages from unknown senders:
Block phone numbers, contacts, and emails on your iPhone, iPad, or iPod touch - Apple Support
While you would not see a notification for missed calls from blocked contacts or numbers, they would still be able to leave a voicemail. You can also turn on Silence Unknown Callers, however this does allow notifications to be sent for missed calls. There's also some third-party apps you may want to look at in the App Store that can help detect and block spam phone calls:
Detect and block spam phone calls - Apple Support
Beyond that, you'll want to speak with your carrier to determine if there are additional options that can be taken on your account to prevent unknown callers from reaching you.
Take care.