Problem
When the API for adding an app shortcut to the home screen is called, error code 401 is returned, indicating invalid parameters.
Possible causes
-
One or more of the following issues exist when you call the checkPinShortcutPermitted API for checking whether a shortcut can be added to the home screen:
- The context is empty.
- The value of shortcutId contains more than 63 bytes.
- In the target Want of the shortcut, the values of parameters are not of the basic string type, or the key length exceeds 1024 characters.
- The labelResName field of the static shortcut is empty, or the referenced resource does not exist.
- The iconResName field of the static shortcut is empty, or the referenced resource does not exist.
- The custom shortcut name specified by label is empty or contains more than 255 characters.
- You do not have permission to access the custom shortcut icon path specified by foregroundIcon or the file does not exist.
- The custom shortcut icon is not in PNG or WebP format.
- The custom shortcut icon exceeds 100 KB.
- This shortcut belongs to another app.
-
One or more of the following issues exist when you call the requestNewPinShortcut API for adding a shortcut to the home screen:
- The context is empty.
- The value of tid that indicates the shortcut verification result is empty.