Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
88 views
in Technique[技术] by (71.8m points)

ios - Change Text of Custom URL Scheme

I have a custom url scheme added to the iOS calendar event. Is there any way to change the text of the url scheme from being appName:// to something more optically familiar (i.e. click here or https://appName.com).

func addCalendar() {
var eventStore = EKEventStore()
var calendar: EKCalendar?

let calendars = eventStore.calendars(for: .event)
let calendarTitle = "AppName"
let predicate = NSPredicate(format: "title matches %@", calendarTitle)
let filtered = (calendars as NSArray).filtered(using: predicate)

if filtered.count != 0, let filteredCalendar = filtered.first as? EKCalendar {
    calendar = filteredCalendar
    addEvent(with: eventStore, calendar)
} else {
    calendar = EKCalendar(for: .event, eventStore: eventStore)
    calendar?.title = "AppName"
    calendar?.source = eventStore.defaultCalendarForNewEvents?.source
    
    guard let setCalendar = calendar else { return }
    
    do { try eventStore.saveCalendar(setCalendar, commit: true) }
    catch { print("Failed to save calendar") }
    addEvent(with: eventStore, calendar)
}
}

func addEvent(with eventStore: EKEventStore, _ calendar: EKCalendar?) {
guard let calendar = calendar else { return }

if let calendarForEvent = eventStore.calendar(withIdentifier: calendar.calendarIdentifier) {
    let newEvent = EKEvent(eventStore: eventStore)
    
    newEvent.calendar = calendarForEvent
            
    newEvent.title = "Some Title"
    newEvent.startDate = Date()
    newEvent.endDate = Date()
    newEvent.notes = "Some notes"
    newEvent.url = URL(string: "appName://")
    
    do { try eventStore.save(newEvent, span: .thisEvent, commit: true) }
    catch { print("Could not save event to user's calendar.") }
}
}
question from:https://stackoverflow.com/questions/65853747/change-text-of-custom-url-scheme

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...