Thuta Learning
How Mobile Apps Work
IntermediateMobile Developmentintermediate

Device Permissions နှင့် Capabilities

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • Device Permissions နှင့် Capabilities concept ကို နားလည်ရှင်းပြနိုင်ရန်
  • Diagram/checklist ကို ဖတ်ပြီး mobile architecture/decision ဘယ်လို ဆက်စပ်နေသလဲ ခြေရာခံနိုင်ရန်
  • ကိုယ့် mobile app project အတွက် ဘယ်လို အသုံးချသင့်သလဲ ရှင်းပြနိုင်ရန်

နားလည်ထားရမယ့် အချက်

Mobile app တွေက camera, location, notifications စတဲ့ device capability တွေကို အသုံးချနိုင်ပေမယ့် အားလုံးဟာ user ရဲ့ explicit permission ကို အရင်လိုအပ်ပါတယ်။ OS ဟာ request grant ဖြစ်မဖြစ် အဆုံးအဖြတ်ပေးသူ ဖြစ်ပါတယ်။

Universal architecture: feature needs capability -> in-context ရှင်းပြ -> request permission -> allowed ဆိုရင် feature အလုပ်လုပ်၊ denied ဆိုရင် graceful fallback။

Launch အချိန်မှာ တောင်းလိုက်ခြင်းကို ရှောင်ပါ

App launch မှာ permission အားလုံးကို တောင်းတာဟာ context မရှိသေးတဲ့ decision တွေနဲ့ user ကို လွှမ်းမိုးစေပြီး reflexive denial ကို ဖြစ်စေတတ်ပါတယ်။

Denial ဟာ crash ဖြစ်စေရမယ့် failure state မဟုတ်ပါဘူး — location denial ဆိုရင် location-dependent feature ကိုသာ disable လုပ်ပြီး ကျန်အပိုင်းကို အသုံးပြုနိုင်အောင် ထားသင့်ပါတယ်။

text
PERMISSION REQUEST FLOW
-----------------------
PERMISSION REQUEST FLOW
-----
Feature needs a capability (camera, location, etc.)
        |
        v
Explain why, in context (not at app launch)
        |
        v
Request permission from the OS
        |
   +----+----+
   |         |
Allowed    Denied
   |         |
   v         v
Feature    Graceful fallback
 works     (not a broken feature)

လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်

App တစ်ခု လုပ်နေတဲ့ permission request တိုင်းကို audit လုပ်ပါ — specific action နဲ့ ချိတ်ဆက်ထားလား၊ explanation ပါလား၊ user "No" ဆိုရင် feature ဘာဖြစ်သွားမလဲ။

explanation မပါဘဲ launch မှာ camera ကို ချက်ချင်းတောင်းတဲ့ app ဟာ user ကို reflexive "Deny" လေ့ကျင့်ပေးသလိုဖြစ်ပြီး၊ camera icon tap ရင်မှ trigger ဖြစ်ပြီး line တစ်ကြောင်း explanation ပါတဲ့ request ကတော့ ပိုများစွာ grant ဖြစ်သည်။

Graceful fallback ဟာ good practice ရဲ့ ကျန်တဲ့တစ်ဝက်ပါ — location denied ဖြစ်ရင် delivery app ဟာ ပျက်နေတဲ့ map အစား address manual ရိုက်ခွင့်ပြုနိုင်ပါတယ်။

Permission Request Best Practices

အတူတူ စမ်းရေးကြည့်မယ်

javascript
function followsPermissionBestPractice(request) {
  const { isRequestedInContext, hasExplanation, isRequestedAtLaunch } = request;
  const issues = [];
  if (!isRequestedInContext) issues.push("not requested in the context of actual feature use");
  if (!hasExplanation) issues.push("no explanation given before requesting");
  if (isRequestedAtLaunch) issues.push("requested at app launch instead of when needed");
  return { followsBestPractice: issues.length === 0, issues };
}

const cameraRequestDoneWell = {
  isRequestedInContext: true,
  hasExplanation: true,
  isRequestedAtLaunch: false
};

const locationRequestDonePoorly = {
  isRequestedInContext: false,
  hasExplanation: false,
  isRequestedAtLaunch: true
};

console.log("Camera request done well:", JSON.stringify(followsPermissionBestPractice(cameraRequestDoneWell)));
console.log("Location request done poorly:", JSON.stringify(followsPermissionBestPractice(locationRequestDonePoorly), null, 2));
You should see
Camera request done well: {"followsBestPractice":true,"issues":[]}
Location request done poorly: {
  "followsBestPractice": false,
  "issues": [
    "not requested in the context of actual feature use",
    "no explanation given before requesting",
    "requested at app launch instead of when needed"
  ]
}

အကောင်းဆုံး request ဟာ issue လုံးဝမရှိပြီး၊ launch မှာ explanation မပါဘဲ blind တောင်းတဲ့ request ကတော့ issue သုံးမျိုးလုံး ပါဝင်နေတာကို တွေ့ရသည်။

၅ မိနစ် စမ်းကြည့်

`followsPermissionBestPractice` ကို ပြန်ရေးပြီး fourth flag `deniedPreviously` ကိုပါ စစ်ဆေးအောင် ထည့်ပါ — launch မှာ ထပ်တောင်းတဲ့ request ကို ပိုပြင်းထန်တဲ့ warning အဖြစ် downgrade လုပ်ပါ — အရင်တစ်ကြိမ် deny ခံခဲ့ဖူးတဲ့ request တစ်ခုနဲ့ စမ်းသပ်ပါ။

သတိလေးတစ်ချက်

App launch မှာ permission (camera, location, notifications) အားလုံးကို တစ်ပြိုင်နက် တောင်းခြင်း

Permission denied ဖြစ်ရင် feature တစ်ခုတည်းမဟုတ်ဘဲ app တစ်ခုလုံးကို crash ဖြစ် (သို့) usable မဖြစ်အောင် ချန်ထားခြင်း

Permissions overview — Android DevelopersHow Mobile Apps Work

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • App launch မှာ permission (camera, location, notifications) အားလုံးကို တစ်ပြိုင်နက် တောင်းခြင်း
  • Permission denied ဖြစ်ရင် feature တစ်ခုတည်းမဟုတ်ဘဲ app တစ်ခုလုံးကို crash ဖြစ် (သို့) usable မဖြစ်အောင် ချန်ထားခြင်း
  • ဒီ course က Android Development, Flutter, iOS Development, React Native tutorial တွေကို ထပ်မသင်ပါ — framework hands-on depth အတွက် အဲဒီ course တွေဆီ ဆက်သွားပါ။ ဒီ course က framework-neutral mobile architecture, decision-making, build/deployment/security concept တွေကိုသာ သင်ပေးပါတယ်။

လေ့ကျင့်ခန်း

`followsPermissionBestPractice` ကို ပြန်ရေးပြီး fourth flag `deniedPreviously` ကိုပါ စစ်ဆေးအောင် ထည့်ပါ — launch မှာ ထပ်တောင်းတဲ့ request ကို ပိုပြင်းထန်တဲ့ warning အဖြစ် downgrade လုပ်ပါ — အရင်တစ်ကြိမ် deny ခံခဲ့ဖူးတဲ့ request တစ်ခုနဲ့ စမ်းသပ်ပါ။

You'll know it worked when: Camera request done well: {"followsBestPractice":true,"issues":[]} Location request done poorly: { "followsBestPractice": false, "issues": [ "not requested in the context of actual feature use", "no explanation given before requesting", "requested at app launch instead of when needed" ] } အကောင်းဆုံး request ဟာ issue လုံးဝမရှိပြီး၊ launch မှာ explanation မပါဘဲ blind တောင်းတဲ့ request ကတော့ issue သုံးမျိုးလုံး ပါဝင်နေတာကို တွေ့ရသည်။

Device Permissions နှင့် Capabilities | Thuta Learning