Building a prayer times and qibla app: calculation methods, notifications and accuracy
The short answer
A prayer times app calculates each prayer from the sun's position at the user's location and date, using a named calculation method, such as Umm al-Qura in Saudi Arabia, because authorities differ on the twilight definitions for Fajr and Isha and on Asr. A good app defaults to the method used locally, lets the user change the method and add minute offsets, schedules notifications on the device so they fire offline, and finds the qibla from the great-circle bearing to the Kaaba with a calibrated compass.
Key takeaways
- Prayer times are astronomical calculations from latitude, longitude, date and time zone, interpreted through a calculation method.
- Methods differ mainly in how Fajr and Isha are defined, so the app should default to the local authority's method and show which method is in use.
- Asr has two common settings: the majority view and the Hanafi view, which gives a later Asr.
- Adhan notifications must be scheduled ahead on the device, because iOS and Android restrict background work.
- The qibla is the initial great-circle bearing to the Kaaba, corrected from magnetic to true north.
How prayer times are calculated
Prayer times are calculated from the position of the sun relative to the user's location on a given date. Each prayer is tied to a solar event, and standard astronomical formulas give the sun's position for any date, latitude and longitude:
- Fajr begins at true dawn, defined in calculation as the moment the sun reaches a set angle below the horizon before sunrise.
- Sunrise is shown because it marks the end of Fajr time, even though it is not a prayer.
- Dhuhr begins just after solar noon, when the sun passes its highest point.
- Asr is defined by the length of an object's shadow, discussed below.
- Maghrib begins at sunset.
- Isha begins when evening twilight disappears, defined either by an angle below the horizon or, in some methods, by a fixed interval after Maghrib.
The inputs are latitude, longitude, the date and the time zone, including any daylight saving rules where they apply. Some apps also consider elevation for sunrise and sunset. Because everything comes from formulas, the whole calculation can run on the phone with no server and no connection, which is the right design for an app people rely on several times a day.
Why calculation methods differ, and which one to use
Calculation methods differ because authorities define dawn and nightfall differently. The main variable is the angle of the sun below the horizon used for Fajr and Isha; a few methods use a fixed interval after Maghrib for Isha instead. A small difference in angle can move Fajr by several minutes, more at higher latitudes.
| Method | Where it is commonly used | How it differs |
|---|---|---|
| Umm al-Qura | Saudi Arabia, where it underpins the official calendar and timetables | Fajr by an angle; Isha at a fixed interval after Maghrib rather than by an angle, with a longer interval in Ramadan |
| Muslim World League | Widely used as a general default in many countries | Twilight angles for both Fajr and Isha |
| Egyptian General Authority of Survey | Egypt and a number of other countries in the region | Twilight angles for both Fajr and Isha, with an earlier Fajr than many methods |
| Local official methods | Several countries, including some in the Gulf, publish their own timetables | Parameters set by the national authority |
The practical rule is simple: default to the method used by the local authority and the local mosques, detected from the user's country, and say which method is in use on the main screen. During testing, compare the app's output against the official published timetable for several cities and seasons. If the numbers disagree by more than a minute or two, check the method, the time zone, the rounding and any precautionary minutes the authority adds to its published times.
Asr settings and high-latitude adjustments
Asr has two widely used settings, reflecting a difference between the schools of jurisprudence. In the majority view, held by the Shafi'i, Maliki and Hanbali schools, Asr begins when an object's shadow equals its length plus the shadow it had at noon. In the Hanafi view, it begins when the shadow reaches twice the object's length plus the noon shadow, which gives a later time. The app should default to the setting common in the user's country and offer the other clearly labelled.
High latitudes need special handling. In summer, far from the equator, the sun may not go deep enough below the horizon for the twilight angle ever to be reached, so a pure angle-based calculation produces no Fajr or Isha time at all, or an unrealistic one. Libraries and authorities use adjustment rules for this, commonly known as middle of the night, one-seventh of the night, and angle-based (twilight angle as a proportion of the night).
For an app focused on Saudi Arabia and the Gulf, these rules rarely change anything at home. They matter for users who travel or study abroad, which is common. Choose a default rule with the scholars who review the app, document it in the settings, and test cities in northern Europe in June as part of the test suite.
Settings, offsets and location privacy
Give users control without making them configure anything on day one. The settings screen of a well-built prayer times app usually offers:
- Calculation method, pre-selected from the user's country.
- Asr setting: majority or Hanafi.
- High-latitude rule, shown only when relevant.
- Manual offsets in minutes per prayer, so a user can match their local mosque's timetable exactly.
- Location mode: automatic, or a city chosen manually for users who prefer not to share location.
- Hijri date adjustment of a day forward or back.
Location is personal data, so ask for the least you need. Permission "while using the app" is enough to calculate times; the coordinates can stay on the device, and the app only needs to recalculate when the user moves to another city. Explain the request in plain words before the system prompt appears. Disclose location use honestly in the Apple App Store privacy details and the Google Play data safety section, and keep in mind that personal data in Saudi Arabia falls under the Personal Data Protection Law (PDPL); confirm specifics with qualified counsel.
Remember the difference between the adhan time and the iqama. Mosques set their own iqama times, so an app that serves a mosque community may add a mosque-managed iqama schedule alongside the calculated times rather than mixing the two.
Reliable adhan notifications on iOS and Android
Reliable notifications come from scheduling them in advance on the device, because neither iOS nor Android lets an app run freely in the background to check the time. This is where most prayer apps earn or lose their reviews.
- Schedule ahead as local notifications. Calculate the coming days and register each prayer as a scheduled notification. They fire offline and survive the app being closed.
- Refresh the window. iOS caps how many local notifications an app may have pending, so schedule a rolling window and top it up whenever the app opens or gets background time.
- Respect sound limits. iOS plays only a short custom sound for a notification, so a full adhan cannot be the notification sound; use a short adhan excerpt, and play the full adhan only if the user opens the app.
- Handle Android's restrictions. Recent Android versions restrict exact alarms behind a permission, and Google Play policy limits which apps may declare the related permissions, so check the current rules. Some manufacturers' battery optimisation delays or cancels background work. Request what is needed, explain why, and guide users to exclude the app from battery optimisation where it helps.
- Re-schedule after changes. A new method, offset, time zone, reboot or location change must rebuild the schedule.
- Test on real devices. Emulators do not reproduce manufacturer battery behaviour. Test across several brands and OS versions before release.
Keep notification options humane: per-prayer on and off, adhan or silent alert, a reminder some minutes before, and respect for the phone's silent and focus modes. A pre-Fajr alert is helpful for some users and unwelcome for others, so make it opt-in.
How qibla direction and Hijri dates work
The qibla direction is the initial bearing of the great-circle route from the user's location to the Kaaba in Makkah, the shortest path over the surface of the Earth. It is calculated with standard spherical trigonometry from the two sets of coordinates. A straight line on a flat map gives a different and wrong answer for distant locations, which is a classic bug.
The compass is the harder part. A phone's magnetometer measures magnetic north, which differs from true north by the local magnetic declination; both iOS and Android provide ways to obtain a true heading or the declination for a location. The sensor is also disturbed by metal, magnets in phone cases and nearby electronics. A good qibla screen asks the user to calibrate when accuracy is low, shows the accuracy honestly, and offers a map view that draws the great-circle path towards Makkah, so the user can line it up with streets or buildings without relying on the compass.
Hijri dates need humility. The Umm al-Qura calendar is the official Hijri calendar in Saudi Arabia and can be calculated in advance. But the start of months tied to worship, such as Ramadan, Shawwal and Dhu al-Hijjah, is confirmed by moon sighting and announced officially, and may differ from the calculated date by a day. Show the calculated date as expected, let users adjust by a day, and if the app has a server, push an official correction when an announcement is made.
Planning a prayer times app, and how it connects to Quran features
A prayer times app is a precision tool, so the first release should be narrow and exact: correct times with a visible method, reliable notifications, a qibla screen with honest accuracy, the Hijri date, offline operation and a calm Arabic-first interface. Everything else can wait until users trust the times.
Many organisations then want to grow it into a fuller daily companion: adhkar linked to prayer times, as described in what a good adhkar app needs, a Quran reader, and gentle reading goals, as covered in designing Quran habit features. For the reader itself, see what a Quran app needs.
Aalim, the Quran learning app FLUIDS designed and built, does not include prayer times or qibla. What carries over are its foundations: a calm reader in authentic Uthmani script, surahs available offline, Arabic-first design, and reading kept separate from AI features that need a connection. Those are the same foundations a combined prayer and Quran app needs.
FLUIDS builds mobile apps and custom software for organisations and founders in Saudi Arabia and the GCC, and the client owns the source code. Start with the mobile app MVP guide or the Aalim case study; scope, price and timeline are agreed in a written proposal before development.
Frequently asked questions
Why do prayer apps show different times?
Usually because they use different calculation methods, Asr settings or time zones, or because the location is imprecise. Checking the method in settings and matching it to the local official timetable normally resolves the difference.
Which calculation method is used in Saudi Arabia?
Umm al-Qura is the method associated with Saudi Arabia's official calendar and timetables. An app serving Saudi users should default to it and still allow other methods.
Does a prayer times app need the internet?
No. Times can be calculated on the phone from the location and date, and notifications can be scheduled locally. A connection helps only for map views, content updates or official date corrections.
Why is my qibla compass wrong?
Phone compasses are disturbed by metal, magnetic cases and electronics, and need calibration. Move away from interference, calibrate, and cross-check with a map view that draws the line towards Makkah.
Can FLUIDS build a prayer times app for our organisation?
Yes. We agree the audience, countries, default methods and any adhkar or Quran features first, then scope calculation, notifications and qibla. Price and timeline are confirmed in a written proposal before development.
Further reading
Related development services
From the idea to a working product
Quran & Islamic apps
Keep reading
Adhkar and dua apps
What a good adhkar and dua app needs: authentic sources, reminders and offline use
Quran app features
Quran app features: a checklist for a reader people trust
Quran habit features
Designing Quran habit features: daily goals, streaks and a werd that respect the Quran
Tahfeedh circle management
Managing a Quran memorization circle with an app: teachers, students and progress
Turn the idea into a written scope
A short call to understand your users and workflow, then a written proposal covering scope, timeline and price before development starts.
Start on WhatsApp