Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
```objective-c
//
// InterfaceController.m
// MMWormhole WatchKit Extension
Expand Down Expand Up @@ -67,6 +68,4 @@ - (IBAction)didTapThree:(id)sender {
}

@end



```
5 changes: 3 additions & 2 deletions Example/MMWormhole/MMWormhole/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
```objective-c
//
// AppDelegate.m
// MMWormhole
Expand All @@ -14,9 +15,9 @@ @interface AppDelegate ()

@implementation AppDelegate


// The AppDelegate class is responsible for handling application-level events and managing the app's lifecycle.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// This method is called when the application has finished launching. It is used to perform any final initialization before the app is presented to the user.
return YES;
}

Expand Down
1 change: 1 addition & 0 deletions Example/MMWormhole/MMWormhole/ViewController.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
```objective-c
//
// ViewController.m
// MMWormhole
Expand Down
1 change: 1 addition & 0 deletions Example/MMWormhole/Today Extension/TodayViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ @implementation TodayViewController
- (void)viewDidLoad {
[super viewDidLoad];

// Initialize the wormhole for message passing
self.wormhole = [[MMWormhole alloc] initWithApplicationGroupIdentifier:@"group.com.mutualmobile.wormhole"
optionalDirectory:@"wormhole"];
}
Expand Down
4 changes: 1 addition & 3 deletions Example/MMWormhole/watchOS Extension/InterfaceController.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
```objective-c
//
// InterfaceController.m
// watchOS Extension
Expand Down Expand Up @@ -74,6 +75,3 @@ - (IBAction)didTapThree:(id)sender {
}

@end



2 changes: 2 additions & 0 deletions Source/MMWormhole.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
```objective-c
//
// MMWormhole.h
//
Expand Down Expand Up @@ -198,3 +199,4 @@ NS_ASSUME_NONNULL_BEGIN
@end

NS_ASSUME_NONNULL_END
```
4 changes: 4 additions & 0 deletions Source/MMWormhole.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
```objective-c
//
// MMWormhole.m
//
Expand Down Expand Up @@ -128,6 +129,7 @@ - (void)dealloc {

#pragma mark - Private Notification Methods

// This method sends a notification for a message with a specific identifier.
- (void)sendNotificationForMessageWithIdentifier:(nullable NSString *)identifier {
CFNotificationCenterRef const center = CFNotificationCenterGetDarwinNotifyCenter();
CFDictionaryRef const userInfo = NULL;
Expand All @@ -136,6 +138,7 @@ - (void)sendNotificationForMessageWithIdentifier:(nullable NSString *)identifier
CFNotificationCenterPostNotification(center, str, NULL, userInfo, deliverImmediately);
}

// This method registers for notifications with a specific identifier.
- (void)registerForNotificationsWithIdentifier:(nullable NSString *)identifier {
[self unregisterForNotificationsWithIdentifier:identifier];

Expand Down Expand Up @@ -170,6 +173,7 @@ void wormholeNotificationCallback(CFNotificationCenterRef center,
userInfo:@{@"identifier" : identifier}];
}

// This method is called when a message notification is received.
- (void)didReceiveMessageNotification:(NSNotification *)notification {
NSDictionary *userInfo = notification.userInfo;
NSString *identifier = [userInfo valueForKey:@"identifier"];
Expand Down
28 changes: 4 additions & 24 deletions Source/MMWormholeSession.h
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
//
// MMWormholeSession.h
//
// Copyright (c) 2015 Mutual Mobile (http://www.mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import "MMWormhole.h"

#import <WatchConnectivity/WatchConnectivity.h>

NS_ASSUME_NONNULL_BEGIN

/**
The MMWormholeSession class provides support for WatchConnectivity-based message passing.
*/
@interface MMWormholeSession : MMWormhole <WCSessionDelegate>

/**
Expand All @@ -53,4 +33,4 @@ NS_ASSUME_NONNULL_BEGIN

@end

NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
5 changes: 4 additions & 1 deletion Source/MMWormholeSession.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
```objective-c
//
// MMWormholeSession.m
//
Expand Down Expand Up @@ -86,6 +87,7 @@ - (void)unregisterForNotificationsWithIdentifier:(nullable NSString *)identifier

#pragma mark - WCSessionDelegate Methods

// This method is called when a message is received from the WatchConnectivity framework.
- (void)session:(nonnull WCSession *)session didReceiveMessage:(nonnull NSDictionary<NSString *,id> *)message {
for (NSString *identifier in message.allKeys) {
NSData *data = message[identifier];
Expand All @@ -95,6 +97,7 @@ - (void)session:(nonnull WCSession *)session didReceiveMessage:(nonnull NSDictio
}
}

// This method is called when an application context is received from the WatchConnectivity framework.
- (void)session:(WCSession *)session didReceiveApplicationContext:(NSDictionary<NSString *, id> *)applicationContext {
for (NSString *identifier in applicationContext.allKeys) {
NSData *data = applicationContext[identifier];
Expand All @@ -104,6 +107,7 @@ - (void)session:(WCSession *)session didReceiveApplicationContext:(NSDictionary<
}
}

// This method is called when a file is received from the WatchConnectivity framework.
- (void)session:(nonnull WCSession *)session didReceiveFile:(nonnull WCSessionFile *)file {
NSString *identifier = file.metadata[@"identifier"];

Expand Down Expand Up @@ -132,4 +136,3 @@ - (void)session:(nonnull WCSession *)session didReceiveFile:(nonnull WCSessionFi
}

@end