You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The above block defines that you will be running the main SMServer server at the subdirectory `/smserver/`, and that you will be running the websocket at the subdirectory `/smserver_websocket/`. You are free to change these directories, but make sure to adjust the next step accordingly if you do. \
39
39
3\. Open the settings of the SMServer app on your host device, and enable 'WebSocket Proxy Compatibility' under 'Web interface Settings'. In the box that appears, enter the subdirectory that the websocket resides at in your reverse proxy (in this case, it is `/smserver_websocket/`, but if you change it you'll need to type in what you set it to instead).
40
40
41
+
### The website stops automatically updating after a while and I have to refresh it to see new texts/an accurate battery percentage.
42
+
43
+
Try disabling the option "Restart server on network change" in the host device's settings. If you're running SMServer behind a reverse proxy, you may also want to look at [this comment](https://github.com/iandwelker/smserver/issues/73#issuecomment-762618203) to see if it helps.
44
+
If neither of these fix it, feel free to file an issue.
45
+
41
46
### How did you make this?
42
47
43
48
In this same directory, there's a document called `IMCore_and_ChatKit.md` that details how I used ChatKit and IMCore for the backend of this app. It should have most things that you'd be interested in. If there are still other questions you'd like to ask or things you don't understand, feel free to DM me at u/Janshai on reddit, or @Janshaidev on twitter.
Copy file name to clipboardExpand all lines: docs/IMCore_and_ChatKit.md
+42-13Lines changed: 42 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,17 +117,37 @@ else
117
117
If you haven't yet texted the person in the previous block of code (the one using `CKConversation`), the `CKConversation` from `[CKConversationList conversationForExistingChatWithGroupID]` will be nil. Just check for that, then execute the code in the most previous block, assuming that `chat` is nil (so that you have to go into the if and create a new chat).
118
118
119
119
## Typing indicators
120
-
This is probably one of the most unsure things I figured out, meaning that there's definitely a better way but I'm just doing the thing that seems to work semi-ok for me. To hijack when someone starts typing using my method, you'll have to first have the MobileSMS app open, or just running in the background. There may be a more reliable way by working through IMDaemon, but I have yet to find it (or even really look for it). Here's the code:
120
+
This isn't the most elegant solution, but it isn't that bad either. In a nutshell, whenever `isCancelTypingMessage` returns `YES`, someone stopped typing, and whenever `isIncomingTypingMessage` returns `YES`, someone started typing. So if you check their values every time, you can do whever you want each time they return `YES`. The full code is below.
121
121
122
122
```objectivec
123
-
%hook IMTypingChatItem
123
+
%hook IMMessageItem
124
124
125
-
- (id)_initWithItem:(id)arg1 {
126
-
id orig = %orig;
125
+
- (bool)isCancelTypingMessage {
126
+
bool orig = %orig;
127
127
128
-
NSString *chat = [(IMMessageItem *)arg1 sender];
129
-
/// Do whatever you want with the chat. Personally, I send it to my app via IPC.
128
+
/// if `orig` is true here, someone stopped typing.
129
+
if (orig) {
130
130
131
+
/// warning: the `IMMessageItem` that this function is running in gets deallocated very quickly after when
132
+
/// this function is called and returns `YES`, so if you do any dispatch_async stuff here and try to call
133
+
/// anything on `self` in the block, it will crash the process this is running in.
134
+
__block NSString* sender = [self sender];
135
+
/// do whatever you want with the conversation in which the other party stopped typing
136
+
}
137
+
138
+
return orig;
139
+
}
140
+
141
+
- (bool)isIncomingTypingMessage {
142
+
bool orig = %orig;
143
+
144
+
/// if `orig` is true here, somebody started typing.
145
+
if (orig) {
146
+
147
+
__block NSString* sender = [self sender];
148
+
/// `sender` is the chat identifier of the conversation in which the other party started typing.
I don't yet know how to send tapbacks on iOS 13-, since the last method used in the code snippet above (`[chat sendMessageAcknowledgment: forChatItem: withAssociatedMessageInfo:]`) doesn't exist in anything before iOS 14. However, there are very similar methods, so I'm fairly certain that it wouldn't be too hard to figure it out. Let me know if you do, and I can add the information here (if you'd like).
182
200
183
201
## Getting pinned chats
184
-
I am actually fairly certain this is the best way to get the list of pinned chats. It's short and easy, so here's the code:
202
+
I am actually fairly certain this is the best way to get the list of pinned chats. It's not as short and easy as I previously thought, but it's not too bad either. The following code gets us an array of all the chat identifiers that correspond to the currently pinned chats.
185
203
186
204
```objectivec
187
205
/// Pinned chats are only available for iOS 14+, so check that first
188
206
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 14.0) {
Const.log("Attempting to load server and socket...", debug:self.debug)
18
+
Const.log("Attempting to load server and socket...")
21
19
22
20
self.server_running = server.startServers()
23
21
24
-
Const.log(self.server_running ?"Successfully started server and socket":"Failed to start server and socket",debug:self.debug,warning: !self.server_running)
22
+
Const.log(self.server_running ?"Successfully started server and socket":"Failed to start server and socket", warning: !self.server_running)
25
23
}
26
24
27
25
func enteredBackground(){
28
26
/// Just waits a minute and then kills the app if you disabled backgrounding. A not graceful way of doing what the system does automatically
29
27
//if !background || !self.server.isListening {
30
28
if !settings.background || !self.server.isRunning(){
0 commit comments