{"id":21855902,"url":"https://github.com/gobelieveio/im_ios","last_synced_at":"2025-08-20T14:31:35.597Z","repository":{"id":28733477,"uuid":"32254774","full_name":"GoBelieveIO/im_ios","owner":"GoBelieveIO","description":"GoBelieveIO IM iOS  sdk","archived":false,"fork":false,"pushed_at":"2022-02-18T12:50:49.000Z","size":36910,"stargazers_count":123,"open_issues_count":2,"forks_count":109,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-12-11T08:12:22.631Z","etag":null,"topics":["free","free-software","gobelieveio","im","ios","objective-c","open-source"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GoBelieveIO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-15T10:30:39.000Z","updated_at":"2024-08-12T19:09:43.000Z","dependencies_parsed_at":"2022-09-04T21:00:21.544Z","dependency_job_id":null,"html_url":"https://github.com/GoBelieveIO/im_ios","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoBelieveIO%2Fim_ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoBelieveIO%2Fim_ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoBelieveIO%2Fim_ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoBelieveIO%2Fim_ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GoBelieveIO","download_url":"https://codeload.github.com/GoBelieveIO/im_ios/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230431103,"owners_count":18224655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["free","free-software","gobelieveio","im","ios","objective-c","open-source"],"created_at":"2024-11-28T02:19:57.866Z","updated_at":"2024-12-19T12:10:00.769Z","avatar_url":"https://github.com/GoBelieveIO.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"#gobelieve iOS\ngobelieve iOS SDK\n\n##生成demo的workspace\n1. cp demo/dev.podspec ./\n2. pod install\n\n##应用集成到自己的客户端\n\n1. podfile\n\n        pod 'gobelieve', :git =\u003e 'https://github.com/GoBelieveIO/im_ios.git'\n\n3. 在AppDelegate初始化deviceID以及message handler\n\n        [IMService instance].deviceID = deviceID;\n        [IMService instance].peerMessageHandler = [PeerMessageHandler instance];\n        [IMService instance].groupMessageHandler = [GroupMessageHandler instance];\n        [IMService instance].customerMessageHandler = [CustomerMessageHandler instance];\n\n4. 在AppDelegate中监听系统网络变化\n\n        -(void)startRechabilityNotifier {\n            self.reach = [GOReachability reachabilityForInternetConnection];\n            self.reach.reachableBlock = ^(GOReachability*reach) {\n                dispatch_async(dispatch_get_main_queue(), ^{\n                    NSLog(@\"internet reachable\");\n                    [[IMService instance] onReachabilityChange:YES];\n                });\n            };\n            \n            self.reach.unreachableBlock = ^(GOReachability*reach) {\n                dispatch_async(dispatch_get_main_queue(), ^{\n                    NSLog(@\"internet unreachable\");\n                    [[IMService instance] onReachabilityChange:NO];\n                });\n            };\n            \n            [self.reach startNotifier];\n\n        }\n\n        [self startRechabilityNotifier];\n        [IMService instance].reachable = [self.reach isReachable];\n\n5. 登录成功之后设置token和uid, token和uid从应用本身的登录接口获得\n\n        [IMService instance].token = \"\"\n        [PeerMessageHandler instance].uid = uid\n        [GroupMessageHandler instance].uid = uid\n        [CustomerMessageHandler instance].uid = uid\n\n        SyncKeyHandler *handler = [[SyncKeyHandler alloc] initWithFileName:fileName];\n        [IMService instance].syncKeyHandler = handler;\n\n6. 初始化消息db\n\n        NSFileManager *fileManager = [NSFileManager defaultManager];\n        if (![fileManager fileExistsAtPath:dbPath]) {\n            NSString *p = [[NSBundle mainBundle] pathForResource:@\"gobelieve\" ofType:@\"db\"];\n            [fileManager copyItemAtPath:p toPath:dbPath error:nil];\n        }\n        FMDatabase *db = [[FMDatabase alloc] initWithPath:dbPath];\n        BOOL r = [db openWithFlags:SQLITE_OPEN_READWRITE|SQLITE_OPEN_WAL vfs:nil];\n        if (!r) {\n            NSLog(@\"open database error:%@\", [db lastError]);\n            db = nil;\n            NSAssert(NO, @\"\");\n        }\n\n        [PeerMessageDB instance].db = db;\n        [GroupMessageDB instance].db = db;\n        [CustomerMessageDB instance].db = db;\n\n7. 启动IMService开始接受消息\n\n        [[IMService instance] start];\n\n8. 添加消息observer，处理相应类型的消息\n\n        //连接状态\n        [[IMService instance] addConnectionObserver:ob];\n\n        //点对点消息\n        [[IMService instance] addPeerMessageObserver:ob];\n        //群组消息\n        [[IMService instance] addGroupMessageObserver:ob];\n        //直播的聊天室消息\n        [[IMService instance] addRoomMessageObserver:ob];\n        //实时消息,用于voip的信令\n        [[IMService instance] addRTMessageObserver:ob];\n        //系统消息\n        [[IMService instance] addSystemMessageObserver:ob];\n\n        \n9. app进入后台,断开socket链接\n\n        [[IMService instance] enterBackground];\n\n\n10. app返回前台,重新链接socket\n \n        [[IMService instance] enterForeground]; \n\n12. 发送点对点消息\n\n        PeerMessageViewController* msgController = [[PeerMessageViewController alloc] init];\n        msgController.peerUID = peerUID;\n        msgController.peerName = @\"\";\n        msgController.currentUID = uid;\n        [self.navigationController pushViewController:msgController animated:YES];\n\n13. 发送群组消息\n\n        GroupMessageViewController* msgController = [[GroupMessageViewController alloc] init];\n        msgController.groupID = groupID;\n        msgController.groupName = @\"\";\n        msgController.currentUID = uid;\n        [self.navigationController pushViewController:msgController animated:YES];\n\n14. 用户注销\n\n        [[IMService instance] stop]","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobelieveio%2Fim_ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgobelieveio%2Fim_ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobelieveio%2Fim_ios/lists"}