블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2737)
Unity3D (817)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
04-20 00:00

READ_PHONE_STATE Permission isn’t in my Manifest or Plugins!

Unity automatically adds the READ_PHONE_STATE permission into builds when either:

  • Your scripts contain code which require the permission.
  • The target SDK version isn’t set (or set below 4) which causes the manifest merger to assume the SDK version is lower than 4 and the system will implicitly grant the READ_PHONE_STATE permission to the app. (in later versions of Unity 5 and Unity 2017 the target SDK version is now set in the editor making managing it much easier)
  • You have a plugin in your project which has its own manifest file requesting the permission (the manifest can be contained within your jar or aar files, they’re not always simply in your project) – Note that if a plugin is requesting a permission then it’s probably required and may cause issues if removed, check the plugin documentation if you’re unsure!

Code which causes Unity to automatically add the permission

In the case of your scripts containing code which need the permission. Unity automatically adds the permission when using functions which require it.

Some SystemInfo properties such as SystemInfo.deviceUniqueIdentifier require the READ_PHONE_STATE permission so referencing it in a script will force Unity to add it.

As an alternative to SystemInfo.deviceUniqueIdentifier when needing a unique device identifier and it’s not important to keep it the same between wiping save data. Consider generating a unique value based on System.DateTime.Now.Ticks and storing in the playerprefs instead.



Why am I asked to allow/deny the permission at app launch?

Starting with Android 6.0 the user was given more control over permissions apps were allowed to use at runtime; rather than a blanket list of confusing permission being included with the app at installation. Permissions which are prompted for the user to allow are classified as dangerous permissions as they can allow the app to access sensitive data. (in this case READ_PHONE_STATE can allow reading of the phone number, call statuses or list phone accounts registered on the device)

If you want to manually control when the permissions are requested at runtime rather than all dangerous permissions just being prompted at startup then you can add:
<meta-data android:name=”unityplayer.SkipPermissionsDialog” android:value=”true” />
Between the <application> tags of your manifest file.

With the permission dialog skipped all dangerous permissions will remain defaulted as denied! But this allows you to request permissions manually when you need them, rather than all at once at app launch. (However note that you’ll either need to write a Java plugin yourself to control this or find an already built plugin from the store such as Android Buddy which fits this exact purpose!)

Learn more about the READ_PHONE_STATE android permission!

You can read more about the READ_PHONE_STATE permission on the android developer site at https://developer.android.com/reference/android/Manifest.permission.html#READ_PHONE_STATE

 

[출처]

https://www.unity3dtips.com/read_phone_state-permission-android/

 

Remove READ_PHONE_STATE Permission Unity Android - Unity3d Tips

How to remove the READ_PHONE_STATE permission in your Unity Android apps and find the cause! Alternatively prompt the permission later than app startup!

www.unity3dtips.com

 

반응형
Posted by blueasa
, |