Small and medium sized magnets should not have any detrimental effect on your smartphone or tablet.
It is quite possible that these devices already contain small magnets which enable them to perform certain functions.
However, it is always wise to keep large, powerful magnets away from any electronic device as strong magnetic fields could possibly damage mechanical parts.