mergNotify is an iOS and OS X external that adds a command to request a notification callback whenever the Notification Center receives the
event notification. Many classes in the iOS SDK have notifications that the external enables your stack to receive. For example, two
notifications from the UIApplication class are UIApplicationWillResignActiveNotification and UIApplicationDidBecomeActiveNotification.
These notifications are send when the app is being opened and closed, the device is switched on or off with the app running or when some
other system notification is presented over the app. There are many other examples of useful notifications in the iOS sdk documentation.
Additionally you can use the external to allow multiple LiveCode controls to receive the same notification which may aid in code modularity.
command mergNotify pNotification,[pDistributed]
This command registers for a notification to be sent to the calling control (me) whenever it occurs. The same notification may be registered by multiple controls in your app. If a single control registers for the same notification multiple times it will receive it multiple times.
- pNotification - The name of the notification your control should receive. The notification will be sent to the control with a single pUserInfo parameter. This parameter is the result of using the description method of the NSNotification userInfo dictionary. Some notifications do not have any userInfo so this parameter may be empty.
- pDistributed - (optional with false default) On OS X this option allows you to use the distributed notification center to recieve notifications from other applications. The parameter has no effect on iOS.
Sets the result to An id for the notification observer to be used by mergNotifyCancel
local sTimeResignedActive constant kMaxTimeResignedBeforeSessionExpires = 300 on openStack mergNotify "UIApplicationWillResignActiveNotification" mergNotify "UIApplicationDidBecomeActiveNotification" end openStack on UIApplicationWillResignActiveNotification pUserInfo put the seconds into sTimeResignedActive end UIApplicationWillResignActiveNotification on UIApplicationDidBecomeActiveNotification pUserInfo if sTimeResignedActive <> "" then if the seconds - sTimeResignedActive > kMaxTimeResignedBeforeSessionExpires then -- show session expired so login again UI end if end if end UIApplicationDidBecomeActiveNotification
command mergNotifyCancel pNotificationID
This command releases the notification observer created by the mergNotify command
- pNotificationID - The id returned by the mergNotify command
command mergNotifyPost pNotification,[pDistributed],[pDeliverImediately]
This command sends a notification
- pNotification - The name of the notification to send
- pDistributed - (optional with false default) On OS X this option allows you to use the distributed notification center to send notifications to other applications. The parameter has no effect on iOS.
- pDeliverImediately - (optional with false default) Specifies when to deliver the notification. When false, the receiver delivers notifications to their observers according to the suspended-notification behavior specified in the corresponding dispatch table entry. When true, the receiver delivers the notification immediately to its observers.