How to tell if EKCalendar is a Facebook calendar?
Unfortunately, there is no way to tell if a particular calendar is a facebook calendar without using a private API.
I posted a bug report during the iOS 6 beta and an Apple engineer told me that they would fix it for the final release, but it turned out they didn't ...
However, you can check if a particular event is a facebook event:
BOOL isFacebookEvent = [[event.URL host] hasSuffix:@"facebook.com"];
It doesn't work for facebook birthdays though!
source to share
There is still no public API in EventKit, but there is a workaround using only public methods.
Each calendar has a color property: ekCalendar.CGColor
The Facebook calendar color is Facebook Blue, so by comparing the rbg components of the calendar color, you can determine that the calendar is most likely from Facebook.
I wrote a quick extension for UIColor to check if a given color is Facebook Blue (complete with helper functions to make UIColor rgb function faster)
extension UIColor {
struct rgbComponents {
var red : CGFloat
var green : CGFloat
var blue : CGFloat
var alpha : CGFloat
}
func toComponents()->rgbComponents {
var r:CGFloat = 0
var g:CGFloat = 0
var b:CGFloat = 0
var a:CGFloat = 0
var components : rgbComponents
if self.getRed(&r, green: &g, blue: &b, alpha: &a) {
components = rgbComponents(red: r, green: g, blue: b, alpha: a)
} else {
components = rgbComponents(red: 0, green: 0, blue: 0, alpha: 0)
}
return components
}
func isFBBlue()->Bool {
let c = self.toComponents()
let result = c.red == 0.18823529779911041
&& c.green == 0.39215686917304993
&& c.blue == 0.7137255072593689
&& c.alpha == 1.0
return result
}
source to share