MuslimData is an Islamic library that provides Prayer Times (fixed and calculated), Offline Geocoder, Location Search, Azkars (Hisnul Muslim) and 99 Names of Allah.
Fixed and Calculated Prayer Times: Most cities around the world find their prayer times by using some calculations which is based on location (longitude and latitude) but some other cities have fixed time table for their prayer times. This library contains most fixed and calculated prayer times. Now you can contribute it to improve it and also you can use it in Muslim communities or Muslim apps.
If you're upgrading from version 1.x to version 2.x of muslim-data-ios
, please refer to the Migration Guide for detailed instructions on updating your code to accommodate the changes in the latest release.
To run the example project, clone the repo, and run.
- iOS 13.0+
- Xcode 11.0+
MuslimData is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'MuslimData'
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift
compiler.
Once you have your Swift package set up, adding MuslimData as a dependency is as easy as adding it to the dependencies
value of your Package.swift
or the Package list in Xcode.
dependencies: [
.package(url: "https://github.com/kosratdev/muslim-data-ios", .upToNextMajor(from: "2.0.0"))
]
If you prefer to manage your Swift packages via Xcode, you can also add Muslim Data as a dependency using Xcode's UI:
- Open your Xcode project.
- Navigate to the
File
menu >Swift Packages
>Add Package Dependency...
. - Paste the Muslim Data GitHub repository URL (
https://github.com/kosratdev/muslim-data-ios.git
) into the search bar and clickNext
. - Choose the version rule (
Up to Next Major
from version2.0.0
) and clickNext
. - Xcode will resolve the package and integrate it into your project.
There are some location helper methods that provides offline Location Search, Geocoder, Reverse Geocoder, and check a location for fixed prayer times.
You can search for any cities or places around the world and this is useful when a use doesn't have internet connection or user's location is turned off so you can search here:
let locations = try! await MuslimRepository().searchLocation(locationName: "London")
guard let locations = locations, locations.count > 0 else {
print("Location could not be found!")
return
}
print("locations: \(locations)")
Use geocoder to find a location by name.
// Use geocoder to find a location by name.
let location = try! await MuslimRepository().geocoder(countryCode: "GB", locationName: "London")
guard let location = location else {
print("Location name can not be geocoded")
return
}
print("location: \(location)")
Use reverse geocoder to find a location by latitude and longitude.
// Use reverse geocoder to find a location by its latitude and longitude.
let location = try! await MuslimRepository().reverseGeocoder(latitude: 36.654090, longitude: 44.541278)
guard let location = location else {
print("Location name can not be geocoded by latitude and longitude")
return
}
print("location: \(location)")
You can easily get a location prayer times just by passing (Location
, PrayerAttribute
, and Date
) object to getPrayerTimes
method.
// Create location object.
let location = // it should be retrieved from geocoder, reverseGeocoder, or searchLocation methods.
// Crate prayer attributes object.
let attributes = PrayerAttribute(method: .makkah, asrMethod: .shafii, adjustAngle: .angleBased)
// Get prayer times
let prayerTime = try! await MuslimRepository().getPrayerTimes(location: location, date: Date(), attributes: attributes)
print("prayer times: \(prayerTime!)")
print("Fromat prayer times: \(prayerTime!.formatPrayers(.time12))")
print("Format one prayer time: \(prayerTime!.isha.toTime(format: .time24))")
print("next prayer index: \(prayerTime!.nextPrayerIndex())")
print("next prayer interval: \(prayerTime!.nextPrayerInterval())")
print("next prayer time remaining: \(prayerTime!.nextPrayerTimeRemaining())")
Get all azkars from (Hisnul Muslim book) that is categorized by (Category
, Chapter
, and Item
) and also the azkars are available for these languages (en
, ar
, ckb
, fa
, and ru
)
Get all azkar categories and it is localized for the given language.
// Get azkar categories from MuslimData library
let azkarCategories = try! await MuslimRepository().getAzkarCategories(language: .en)
print("Azkar Categories: \(azkarCategories!)")
Get azkar chapters and it is localized for the given language.
// Get azkar chapters from MuslimData library
let azkarChapters = try! await MuslimRepository().getAzkarChapters(language: .en)
print("Azkar Chapters: \(azkarChapters!)")
Get azkar chapters for a specific category and it is localized for the given language.
// Get azkar chapters for a specific category from MuslimData library
let azkarChapters = try! await MuslimRepository().getAzkarChapters(language: .en, categoryId: 2)
print("Azkar Chapters for a category: \(azkarChapters!)")
Get azkar items for a specific chapter and it is localized for the given language.
// Get azkar items for a specific chapter from MuslimData library
let azkarItems = try! await MuslimRepository().getAzkarItems(language: .en, chapterId: 2)
print("azkar items: \(azkarItems!)")
Get 99 Names of Allah with it's translation and now it is available for these languages (en
, ar
, ckb
, fa
, and ru
)
// Get 99 names of allah from MuslimData library
let namesOfAllah = try! await MuslimRepository().getNamesOfAllah(language: .en)
print("Names of Allah: \(namesOfAllah)")
Kosrat D. Ahmed, [email protected]
MuslimData is available under the Apache license. See the LICENSE file for more info.