Ind.ie is now Small Technology Foundation.
Commit f10d0b05 authored by Aral Balkan's avatar Aral Balkan

Got very basic native notifications working for All Friends timeline.

parent 9e5ce642
......@@ -2100,6 +2100,30 @@ DQ
<rect key="frame" x="0.0" y="0.0" width="90" height="341"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tlv-PP-hRX">
<rect key="frame" x="73" y="273" width="21" height="34"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="•" id="Okh-FB-DT7">
<font key="font" metaFont="system" size="16"/>
<color key="textColor" red="0.99215686270000003" green="0.6588235294" blue="0.035294117649999998" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="yR0-83-7xr">
<rect key="frame" x="73" y="141" width="21" height="34"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="•" id="pOt-vs-TZ2">
<font key="font" metaFont="system" size="16"/>
<color key="textColor" red="0.99215686270000003" green="0.6588235294" blue="0.035294117649999998" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tqK-d6-1Gd">
<rect key="frame" x="73" y="82" width="21" height="34"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="•" id="bkc-UT-DYN">
<font key="font" metaFont="system" size="16"/>
<color key="textColor" red="0.99215686270000003" green="0.6588235294" blue="0.035294117649999998" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button tag="100" translatesAutoresizingMaskIntoConstraints="NO" id="C15-cv-xlY" userLabel="Everyone at Ind.ie button" customClass="VerticalTabBarButton" customModule="Heartbeat" customModuleProvider="target">
<rect key="frame" x="20" y="271" width="50" height="50"/>
<constraints>
......@@ -2430,6 +2454,14 @@ DQ
<action selector="profileButtonPressed:" target="1K4-M7-ZQ2" id="8In-uZ-x3i"/>
</connections>
</button>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wDO-yU-595">
<rect key="frame" x="79" y="-6" width="21" height="34"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="•" id="xis-gn-f1c">
<font key="font" metaFont="system" size="16"/>
<color key="textColor" red="0.99215686270000003" green="0.6588235294" blue="0.035294117649999998" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
<connections>
......
......@@ -90,6 +90,9 @@ class MainInterfaceSplitViewController: NSSplitViewController
registerKeyboardShortcuts()
createNotificationHandlers()
// Initialise native notifications
NativeNotification.sharedInstance
}
......
......@@ -24,6 +24,9 @@ public enum NativeNotificationActionNotification:String
public class NativeNotification: NSObject, NSUserNotificationCenterDelegate
{
var allFriendsTimelineUpdateHandler:NotificationHandler?
// MARK: - NativeNotificationType
public enum NativeNotificationType:String
......@@ -37,6 +40,8 @@ public class NativeNotification: NSObject, NSUserNotificationCenterDelegate
case FriendshipRequest = "FriendshipRequest"
case FriendshipAcceptance = "FriendshipAcceptance"
case AllFriendsTimelineMessage = "AllFriendsTimelineMessage"
}
......@@ -62,6 +67,40 @@ public class NativeNotification: NSObject, NSUserNotificationCenterDelegate
// Set the delegate.
NSUserNotificationCenter.defaultUserNotificationCenter().delegate = self
//
// Notification handlers.
//
allFriendsTimelineUpdateHandler = handle(PulseNotification.named(PulseNotification.AllFriendsTimelineUpdated), with: {
notification in
println("GOT ALL FRIENDS NOTIFICATION!!!!!!!!!!!!!!")
let n:NSUserNotification = NSUserNotification()
n.setValue(false, forKey: "_identityImageHasBorder")
n.title = "New message in the All Friends timeline."
n.hasActionButton = true
// n.subtitle = fullName
// n.informativeText = accountHandle
// TODO: Get the image passed in also.
// n.contentImage = i
n.actionButtonTitle = "View"
n.otherButtonTitle = "Ignore"
n.userInfo = ["type": NativeNotificationType.named(.AllFriendsTimelineMessage)] //,"accountHandle": accountHandle, "name": fullName, "deviceID": deviceID]
//
// Private
//
n.setValue(true, forKey: "_showsButtons")
n.setValue(true, forKey: "_poofsOnCancel")
NSUserNotificationCenter.defaultUserNotificationCenter().deliverNotification(n)
})
}
......@@ -156,7 +195,14 @@ public class NativeNotification: NSObject, NSUserNotificationCenterDelegate
// Notify anyone who cares that a friendship request has been accepted.
post(NativeNotificationActionNotification.named(.FriendshipRequestAccepted), from: self, with: userInfo)
}
case NativeNotificationType.named(.AllFriendsTimelineMessage):
println("Person has asked to view the All Friends Timeline…showing it!")
let userInfo = ["timeline":Timelines.sharedInstance[.AllFriends]!]
post(TimelineNavigationRequestNotification, from: nil, with: userInfo)
default:
fatalError("Unknown native notification type received: \(type).")
}
......
......@@ -340,7 +340,7 @@ public class Node: NSObject, WebSocketDelegate
if let pulseEventType = pulseEventType
{
//println("Pulse event type: \(pulseEventType)")
println("Pulse event type: \(pulseEventType)")
post(PulseNotification.named(pulseEventType), from: self, with: json.dictionaryObject)
}
......
false
\ No newline at end of file
true
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment