Browse Source

refactor. event

matrixbirds 5 years ago
parent
commit
504408bc06

+ 77
- 77
android/src/main/java/com/syan/agora/AgoraModule.java View File

@@ -29,7 +29,6 @@ import java.util.Map;
29 29
 import io.agora.rtc.Constants;
30 30
 import io.agora.rtc.IAudioEffectManager;
31 31
 import io.agora.rtc.IRtcEngineEventHandler;
32
-import io.agora.rtc.PublisherConfiguration;
33 32
 import io.agora.rtc.RtcEngine;
34 33
 import io.agora.rtc.live.LiveInjectStreamConfig;
35 34
 import io.agora.rtc.live.LiveTranscoding;
@@ -280,7 +279,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
280 279
                     WritableMap map = Arguments.createMap();
281 280
                     map.putString("message", "AgoraError");
282 281
                     map.putInt("code", code);
283
-                    sendEvent(getReactApplicationContext(), "onError", map);
282
+                    sendEvent(getReactApplicationContext(), "error", map);
284 283
                 }
285 284
             });
286 285
         }
@@ -294,7 +293,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
294 293
                     map.putString("channel", channel);
295 294
                     map.putInt("uid", uid);
296 295
                     map.putInt("elapsed", elapsed);
297
-                    sendEvent(getReactApplicationContext(), "onJoinChannelSuccess", map);
296
+                    sendEvent(getReactApplicationContext(), "joinChannelSuccess", map);
298 297
                 }
299 298
             });
300 299
         }
@@ -308,7 +307,8 @@ public class AgoraModule extends ReactContextBaseJavaModule {
308 307
                     map.putString("channel", channel);
309 308
                     map.putInt("uid", uid);
310 309
                     map.putInt("elapsed", elapsed);
311
-                    sendEvent(getReactApplicationContext(), "onReJoinChannelSuccess", map);                }
310
+                    sendEvent(getReactApplicationContext(), "reJoinChannelSuccess", map);
311
+                }
312 312
             });
313 313
         }
314 314
 
@@ -334,7 +334,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
334 334
 
335 335
                     WritableMap map = Arguments.createMap();
336 336
                     map.putMap("stats", statsMap);
337
-                    sendEvent(getReactApplicationContext(), "onLeaveChannel", map);
337
+                    sendEvent(getReactApplicationContext(), "leaveChannel", map);
338 338
                 }
339 339
             });
340 340
         }
@@ -347,7 +347,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
347 347
                     WritableMap map = Arguments.createMap();
348 348
                     map.putInt("oldRole", oldRole);
349 349
                     map.putInt("newRole", newRole);
350
-                    sendEvent(getReactApplicationContext(), "onClientRoleChanged", map);
350
+                    sendEvent(getReactApplicationContext(), "clientRoleChanged", map);
351 351
                 }
352 352
             });
353 353
         }
@@ -360,7 +360,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
360 360
                     WritableMap map = Arguments.createMap();
361 361
                     map.putInt("uid", uid);
362 362
                     map.putInt("elapsed", elapsed);
363
-                    sendEvent(getReactApplicationContext(), "onUserJoined", map);
363
+                    sendEvent(getReactApplicationContext(), "userJoined", map);
364 364
                 }
365 365
             });
366 366
         }
@@ -373,7 +373,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
373 373
                     WritableMap map = Arguments.createMap();
374 374
                     map.putInt("uid", uid);
375 375
                     map.putInt("reason", reason);
376
-                    sendEvent(getReactApplicationContext(), "onUserOffline", map);
376
+                    sendEvent(getReactApplicationContext(), "userOffline", map);
377 377
                 }
378 378
             });
379 379
         }
@@ -386,7 +386,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
386 386
                     WritableMap map = Arguments.createMap();
387 387
                     map.putInt("state", state);
388 388
                     map.putInt("reason", reason);
389
-                    sendEvent(getReactApplicationContext(), "onConnectionStateChanged", map);
389
+                    sendEvent(getReactApplicationContext(), "connectionStateChanged", map);
390 390
                 }
391 391
             });
392 392
         }
@@ -398,8 +398,8 @@ public class AgoraModule extends ReactContextBaseJavaModule {
398 398
                 @Override
399 399
                 public void run() {
400 400
                     WritableMap map = Arguments.createMap();
401
-                    map.putString("message", "onConnectionLost");
402
-                    sendEvent(getReactApplicationContext(), "onConnectionLost", map);
401
+                    map.putString("message", "connectionLost");
402
+                    sendEvent(getReactApplicationContext(), "connectionLost", map);
403 403
                 }
404 404
             });
405 405
         }
@@ -414,7 +414,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
414 414
                         map.putInt("error", code);
415 415
                         map.putString("api", api);
416 416
                         map.putString("result", result);
417
-                        sendEvent(getReactApplicationContext(), "onApiCallExecuted", map);
417
+                        sendEvent(getReactApplicationContext(), "apiCallExecuted", map);
418 418
                     }
419 419
                 }
420 420
             });
@@ -427,7 +427,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
427 427
                 public void run() {
428 428
                     WritableMap map = Arguments.createMap();
429 429
                     map.putString("token", token);
430
-                    sendEvent(getReactApplicationContext(), "onTokenPrivilegeWillExpire", map);
430
+                    sendEvent(getReactApplicationContext(), "tokenPrivilegeWillExpire", map);
431 431
                 }
432 432
             });
433 433
         }
@@ -439,7 +439,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
439 439
                 public void run() {
440 440
                     WritableMap map = Arguments.createMap();
441 441
                     map.putString("message", "RequestToken");
442
-                    sendEvent(getReactApplicationContext(), "onRequestToken", map);
442
+                    sendEvent(getReactApplicationContext(), "requestToken", map);
443 443
                 }
444 444
             });
445 445
         }
@@ -451,7 +451,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
451 451
                 public void run() {
452 452
                     WritableMap map = Arguments.createMap();
453 453
                     map.putBoolean("enabled", enabled);
454
-                    sendEvent(getReactApplicationContext(), "onMicrophoneEnabled", map);
454
+                    sendEvent(getReactApplicationContext(), "microphoneEnabled", map);
455 455
                 }
456 456
 
457 457
             });
@@ -474,7 +474,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
474 474
                     WritableMap map = Arguments.createMap();
475 475
                     map.putArray("speakers", arr);
476 476
                     map.putInt("totalVolume", totalVolume);
477
-                    sendEvent(getReactApplicationContext(), "onAudioVolumeIndication", map);
477
+                    sendEvent(getReactApplicationContext(), "audioVolumeIndication", map);
478 478
                 }
479 479
             });
480 480
         }
@@ -486,7 +486,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
486 486
                 public void run() {
487 487
                     WritableMap map = Arguments.createMap();
488 488
                     map.putInt("uid", uid);
489
-                    sendEvent(getReactApplicationContext(), "onActiveSpeaker", map);
489
+                    sendEvent(getReactApplicationContext(), "activeSpeaker", map);
490 490
                 }
491 491
             });
492 492
         }
@@ -498,7 +498,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
498 498
                 public void run() {
499 499
                     WritableMap map = Arguments.createMap();
500 500
                     map.putInt("elapsed", elapsed);
501
-                    sendEvent(getReactApplicationContext(), "onFirstLocalAudioFrame", map);
501
+                    sendEvent(getReactApplicationContext(), "firstLocalAudioFrame", map);
502 502
                 }
503 503
             });
504 504
         }
@@ -511,7 +511,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
511 511
                     WritableMap map = Arguments.createMap();
512 512
                     map.putInt("uid", uid);
513 513
                     map.putInt("elapsed", elapsed);
514
-                    sendEvent(getReactApplicationContext(), "onFirstRemoteAudioFrame", map);
514
+                    sendEvent(getReactApplicationContext(), "firstRemoteAudioFrame", map);
515 515
                 }
516 516
             });
517 517
         }
@@ -523,7 +523,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
523 523
                 public void run() {
524 524
                     WritableMap map = Arguments.createMap();
525 525
                     map.putString("message", "VideoStopped");
526
-                    sendEvent(getReactApplicationContext(), "onVideoStopped", map);
526
+                    sendEvent(getReactApplicationContext(), "videoStopped", map);
527 527
                 }
528 528
             });
529 529
         }
@@ -537,7 +537,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
537 537
                     map.putInt("width", width);
538 538
                     map.putInt("height", height);
539 539
                     map.putInt("elapsed", elapsed);
540
-                    sendEvent(getReactApplicationContext(), "onFirstLocalVideoFrame", map);
540
+                    sendEvent(getReactApplicationContext(), "firstLocalVideoFrame", map);
541 541
                 }
542 542
             });
543 543
         }
@@ -555,7 +555,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
555 555
                     map.putInt("width", width);
556 556
                     map.putInt("height", height);
557 557
                     map.putInt("elapsed", elapsed);
558
-                    sendEvent(getReactApplicationContext(), "onFirstRemoteVideoDecoded", map);
558
+                    sendEvent(getReactApplicationContext(), "firstRemoteVideoDecoded", map);
559 559
                 }
560 560
             });
561 561
         }
@@ -570,7 +570,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
570 570
                     map.putInt("width", width);
571 571
                     map.putInt("height", height);
572 572
                     map.putInt("elapsed", elapsed);
573
-                    sendEvent(getReactApplicationContext(), "onFirstRemoteVideoFrame", map);
573
+                    sendEvent(getReactApplicationContext(), "firstRemoteVideoFrame", map);
574 574
                 }
575 575
             });
576 576
         }
@@ -583,7 +583,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
583 583
                     WritableMap map = Arguments.createMap();
584 584
                     map.putInt("uid", uid);
585 585
                     map.putBoolean("muted", muted);
586
-                    sendEvent(getReactApplicationContext(), "onUserMuteAudio", map);
586
+                    sendEvent(getReactApplicationContext(), "userMuteAudio", map);
587 587
                 }
588 588
             });
589 589
         }
@@ -596,7 +596,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
596 596
                     WritableMap map = Arguments.createMap();
597 597
                     map.putInt("uid", uid);
598 598
                     map.putBoolean("muted", muted);
599
-                    sendEvent(getReactApplicationContext(), "onUserMuteVideo", map);
599
+                    sendEvent(getReactApplicationContext(), "userMuteVideo", map);
600 600
                 }
601 601
             });
602 602
         }
@@ -609,7 +609,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
609 609
                     WritableMap map = Arguments.createMap();
610 610
                     map.putInt("uid", uid);
611 611
                     map.putBoolean("muted", muted);
612
-                    sendEvent(getReactApplicationContext(), "onUserEnableVideo", map);
612
+                    sendEvent(getReactApplicationContext(), "userEnableVideo", map);
613 613
                 }
614 614
             });
615 615
         }
@@ -622,7 +622,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
622 622
                     WritableMap map = Arguments.createMap();
623 623
                     map.putInt("uid", uid);
624 624
                     map.putBoolean("muted", muted);
625
-                    sendEvent(getReactApplicationContext(), "onUserEnableLocalVideo", map);
625
+                    sendEvent(getReactApplicationContext(), "userEnableLocalVideo", map);
626 626
                 }
627 627
             });
628 628
         }
@@ -637,7 +637,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
637 637
                     map.putInt("width", width);
638 638
                     map.putInt("height", height);
639 639
                     map.putInt("rotation", rotation);
640
-                    sendEvent(getReactApplicationContext(), "onVideoSizeChanged", map);
640
+                    sendEvent(getReactApplicationContext(), "videoSizeChanged", map);
641 641
                 }
642 642
             });
643 643
         }
@@ -650,7 +650,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
650 650
                     WritableMap map = Arguments.createMap();
651 651
                     map.putInt("uid", uid);
652 652
                     map.putInt("state", state);
653
-                    sendEvent(getReactApplicationContext(), "onRemoteVideoStateChanged", map);
653
+                    sendEvent(getReactApplicationContext(), "remoteVideoStateChanged", map);
654 654
                 }
655 655
             });
656 656
         }
@@ -662,7 +662,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
662 662
                 public void run() {
663 663
                     WritableMap map = Arguments.createMap();
664 664
                     map.putBoolean("isFallbackOrRecover", isFallbackOrRecover);
665
-                    sendEvent(getReactApplicationContext(), "onLocalPublishFallbackToAudioOnly", map);
665
+                    sendEvent(getReactApplicationContext(), "localPublishFallbackToAudioOnly", map);
666 666
                 }
667 667
             });
668 668
         }
@@ -675,7 +675,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
675 675
                     WritableMap map = Arguments.createMap();
676 676
                     map.putInt("uid", uid);
677 677
                     map.putBoolean("isFallbackOrRecover", isFallbackOrRecover);
678
-                    sendEvent(getReactApplicationContext(), "onRemoteSubscribeFallbackToAudioOnly", map);
678
+                    sendEvent(getReactApplicationContext(), "remoteSubscribeFallbackToAudioOnly", map);
679 679
                 }
680 680
             });
681 681
         }
@@ -687,7 +687,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
687 687
                 public void run() {
688 688
                     WritableMap map = Arguments.createMap();
689 689
                     map.putInt("routing", routing);
690
-                    sendEvent(getReactApplicationContext(), "onAudioRouteChanged", map);
690
+                    sendEvent(getReactApplicationContext(), "audioRouteChanged", map);
691 691
                 }
692 692
             });
693 693
         }
@@ -699,7 +699,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
699 699
                 public void run() {
700 700
                     WritableMap map = Arguments.createMap();
701 701
                     map.putString("message", "CameraDidReady");
702
-                    sendEvent(getReactApplicationContext(), "onCameraReady", map);
702
+                    sendEvent(getReactApplicationContext(), "cameraReady", map);
703 703
                 }
704 704
             });
705 705
         }
@@ -716,7 +716,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
716 716
                     rectMap.putInt("left", rect.left);
717 717
                     WritableMap map = Arguments.createMap();
718 718
                     map.putMap("rect", rectMap);
719
-                    sendEvent(getReactApplicationContext(), "onCameraFocusAreaChanged", map);
719
+                    sendEvent(getReactApplicationContext(), "cameraFocusAreaChanged", map);
720 720
                 }
721 721
             });
722 722
         }
@@ -733,7 +733,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
733 733
                     rectMap.putInt("left", rect.left);
734 734
                     WritableMap map = Arguments.createMap();
735 735
                     map.putMap("rect", rectMap);
736
-                    sendEvent(getReactApplicationContext(), "onCameraExposureAreaChanged", map);
736
+                    sendEvent(getReactApplicationContext(), "cameraExposureAreaChanged", map);
737 737
                 }
738 738
             });
739 739
         }
@@ -760,7 +760,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
760 760
 
761 761
                     WritableMap map = Arguments.createMap();
762 762
                     map.putMap("stats", statsMap);
763
-                    sendEvent(getReactApplicationContext(), "onRtcStats", map);
763
+                    sendEvent(getReactApplicationContext(), "rtcStats", map);
764 764
                 }
765 765
             });
766 766
         }
@@ -772,7 +772,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
772 772
                 public void run() {
773 773
                     WritableMap map = Arguments.createMap();
774 774
                     map.putInt("quality", quality);
775
-                    sendEvent(getReactApplicationContext(), "onLastmileQuality", map);
775
+                    sendEvent(getReactApplicationContext(), "lastmileQuality", map);
776 776
                 }
777 777
             });
778 778
         }
@@ -786,7 +786,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
786 786
                     map.putInt("uid", uid);
787 787
                     map.putInt("txQuality", txQuality);
788 788
                     map.putInt("rxQuality", rxQuality);
789
-                    sendEvent(getReactApplicationContext(), "onNetworkQuality", map);
789
+                    sendEvent(getReactApplicationContext(), "networkQuality", map);
790 790
                 }
791 791
             });
792 792
         }
@@ -803,7 +803,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
803 803
 
804 804
                     WritableMap map = Arguments.createMap();
805 805
                     map.putMap("stats", statsMap);
806
-                    sendEvent(getReactApplicationContext(), "onLocalVideoStats", map);
806
+                    sendEvent(getReactApplicationContext(), "localVideoStats", map);
807 807
                 }
808 808
             });
809 809
         }
@@ -821,7 +821,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
821 821
                     statsMap.putInt("rxStreamType", stats.rxStreamType);
822 822
                     WritableMap map = Arguments.createMap();
823 823
                     map.putMap("stats", statsMap);
824
-                    sendEvent(getReactApplicationContext(), "onRemoteVideoStats", map);
824
+                    sendEvent(getReactApplicationContext(), "remoteVideoStats", map);
825 825
                 }
826 826
             });
827 827
         }
@@ -839,7 +839,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
839 839
                     statsMap.putInt("audioLossRate", stats.audioLossRate);
840 840
                     WritableMap map = Arguments.createMap();
841 841
                     map.putMap("stats", statsMap);
842
-                    sendEvent(getReactApplicationContext(), "onRemoteAudioStats", map);
842
+                    sendEvent(getReactApplicationContext(), "remoteAudioStats", map);
843 843
                 }
844 844
             });
845 845
         }
@@ -859,7 +859,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
859 859
                     statsMap.putInt("rxKBitRate", rxKBitRate);
860 860
                     WritableMap map = Arguments.createMap();
861 861
                     map.putMap("stats", statsMap);
862
-                    sendEvent(getReactApplicationContext(), "onRemoteAudioTransportStats", map);
862
+                    sendEvent(getReactApplicationContext(), "remoteAudioTransportStats", map);
863 863
                 }
864 864
             });
865 865
         }
@@ -879,7 +879,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
879 879
                     statsMap.putInt("rxKBitRate", rxKBitRate);
880 880
                     WritableMap map = Arguments.createMap();
881 881
                     map.putMap("stats", statsMap);
882
-                    sendEvent(getReactApplicationContext(), "onRemoteVideoTransportStats", map);
882
+                    sendEvent(getReactApplicationContext(), "remoteVideoTransportStats", map);
883 883
                 }
884 884
             });
885 885
         }
@@ -891,7 +891,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
891 891
                 public void run() {
892 892
                     WritableMap map = Arguments.createMap();
893 893
                     map.putString("message", "LocalAudioMixingSucceedFinish");
894
-                    sendEvent(getReactApplicationContext(), "onAudioMixingFinish", map);
894
+                    sendEvent(getReactApplicationContext(), "audioMixingFinish", map);
895 895
                 }
896 896
             });
897 897
         }
@@ -903,7 +903,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
903 903
                 public void run() {
904 904
                     WritableMap map = Arguments.createMap();
905 905
                     map.putInt("soundId", soundId);
906
-                    sendEvent(getReactApplicationContext(), "onAudioEffectFinished", map);
906
+                    sendEvent(getReactApplicationContext(), "audioEffectFinished", map);
907 907
                 }
908 908
             });
909 909
         }
@@ -916,7 +916,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
916 916
                     WritableMap map = Arguments.createMap();
917 917
                     map.putString("url", url);
918 918
                     map.putInt("error", error);
919
-                    sendEvent(getReactApplicationContext(), "onStreamPublished", map);
919
+                    sendEvent(getReactApplicationContext(), "streamPublished", map);
920 920
                 }
921 921
             });
922 922
         }
@@ -928,7 +928,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
928 928
                 public void run() {
929 929
                     WritableMap map = Arguments.createMap();
930 930
                     map.putString("url", url);
931
-                    sendEvent(getReactApplicationContext(), "onStreamUnpublished", map);
931
+                    sendEvent(getReactApplicationContext(), "streamUnpublished", map);
932 932
                 }
933 933
             });
934 934
         }
@@ -940,7 +940,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
940 940
                 public void run() {
941 941
                     WritableMap map = Arguments.createMap();
942 942
                     map.putString("message", "TranscodingUpdated");
943
-                    sendEvent(getReactApplicationContext(), "onTranscodingUpdated", map);
943
+                    sendEvent(getReactApplicationContext(), "transcodingUpdated", map);
944 944
                 }
945 945
             });
946 946
         }
@@ -954,7 +954,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
954 954
                     map.putString("url", url);
955 955
                     map.putInt("uid", uid);
956 956
                     map.putInt("status", status);
957
-                    sendEvent(getReactApplicationContext(), "onStreamInjectedStatus", map);
957
+                    sendEvent(getReactApplicationContext(), "streamInjectedStatus", map);
958 958
                 }
959 959
             });
960 960
         }
@@ -972,7 +972,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
972 972
                     map.putInt("uid", uid);
973 973
                     map.putInt("streamId", streamId);
974 974
                     map.putString("data", msg);
975
-                    sendEvent(getReactApplicationContext(), "onStreamMessage", map);
975
+                    sendEvent(getReactApplicationContext(), "streamMessage", map);
976 976
                 }
977 977
             });
978 978
         }
@@ -983,13 +983,13 @@ public class AgoraModule extends ReactContextBaseJavaModule {
983 983
                 @Override
984 984
                 public void run() {
985 985
                     WritableMap map = Arguments.createMap();
986
-                    map.putString("type", "onStreamMessageError");
986
+                    map.putString("type", "streamMessageError");
987 987
                     map.putInt("uid", uid);
988 988
                     map.putInt("streamId", streamId);
989 989
                     map.putInt("error", code);
990 990
                     map.putInt("missed", missed);
991 991
                     map.putInt("cached", cached);
992
-                    sendEvent(getReactApplicationContext(), "onStreamMessageError", map);
992
+                    sendEvent(getReactApplicationContext(), "streamMessageError", map);
993 993
                 }
994 994
             });
995 995
         }
@@ -1000,8 +1000,8 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1000 1000
                 @Override
1001 1001
                 public void run() {
1002 1002
                     WritableMap map = Arguments.createMap();
1003
-                    map.putString("message", "onMediaEngineLoadSuccess");
1004
-                    sendEvent(getReactApplicationContext(), "onMediaEngineLoadSuccess", map);
1003
+                    map.putString("message", "mediaEngineLoadSuccess");
1004
+                    sendEvent(getReactApplicationContext(), "mediaEngineLoadSuccess", map);
1005 1005
                 }
1006 1006
             });
1007 1007
         }
@@ -1012,8 +1012,8 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1012 1012
                 @Override
1013 1013
                 public void run() {
1014 1014
                     WritableMap map = Arguments.createMap();
1015
-                    map.putString("message", "onMediaEngineStartCallSuccess");
1016
-                    sendEvent(getReactApplicationContext(), "onMediaEngineStartCallSuccess", map);
1015
+                    map.putString("message", "mediaEngineStartCallSuccess");
1016
+                    sendEvent(getReactApplicationContext(), "mediaEngineStartCallSuccess", map);
1017 1017
                 }
1018 1018
             });
1019 1019
         }
@@ -1074,7 +1074,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1074 1074
             WritableMap err = Arguments.createMap();
1075 1075
             err.putBoolean("success", false);
1076 1076
             err.putString("message", e.toString());
1077
-            sendEvent(getReactApplicationContext(), "onError", err);
1077
+            sendEvent(getReactApplicationContext(), "error", err);
1078 1078
         }
1079 1079
     }
1080 1080
 
@@ -1088,7 +1088,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1088 1088
             err.putBoolean("success", false);
1089 1089
             err.putString("message", e.toString());
1090 1090
             err.putInt("code", ((ReactNativeAgoraException) e).getCode());
1091
-            sendEvent(getReactApplicationContext(), "onError", err);
1091
+            sendEvent(getReactApplicationContext(), "error", err);
1092 1092
         }
1093 1093
     }
1094 1094
 
@@ -1118,7 +1118,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1118 1118
             WritableMap err = Arguments.createMap();
1119 1119
             err.putBoolean("success", false);
1120 1120
             err.putString("message", e.toString());
1121
-            sendEvent(getReactApplicationContext(), "onError", err);
1121
+            sendEvent(getReactApplicationContext(), "error", err);
1122 1122
         }
1123 1123
     }
1124 1124
 
@@ -1132,7 +1132,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1132 1132
             WritableMap err = Arguments.createMap();
1133 1133
             err.putBoolean("success", false);
1134 1134
             err.putString("message", e.toString());
1135
-            sendEvent(getReactApplicationContext(), "onError", err);
1135
+            sendEvent(getReactApplicationContext(), "error", err);
1136 1136
         }
1137 1137
     }
1138 1138
 
@@ -1155,7 +1155,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1155 1155
             WritableMap err = Arguments.createMap();
1156 1156
             err.putBoolean("success", false);
1157 1157
             err.putString("message", e.toString());
1158
-            sendEvent(getReactApplicationContext(), "onError", err);
1158
+            sendEvent(getReactApplicationContext(), "error", err);
1159 1159
         }
1160 1160
     }
1161 1161
 
@@ -1168,7 +1168,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1168 1168
             WritableMap err = Arguments.createMap();
1169 1169
             err.putBoolean("success", false);
1170 1170
             err.putString("message", e.toString());
1171
-            sendEvent(getReactApplicationContext(), "onError", err);
1171
+            sendEvent(getReactApplicationContext(), "error", err);
1172 1172
         }
1173 1173
     }
1174 1174
 
@@ -1428,7 +1428,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1428 1428
             WritableMap err = Arguments.createMap();
1429 1429
             err.putBoolean("success", false);
1430 1430
             err.putString("message", e.toString());
1431
-            sendEvent(getReactApplicationContext(), "onError", err);
1431
+            sendEvent(getReactApplicationContext(), "error", err);
1432 1432
         }
1433 1433
     }
1434 1434
 
@@ -1441,7 +1441,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1441 1441
             WritableMap err = Arguments.createMap();
1442 1442
             err.putBoolean("success", false);
1443 1443
             err.putString("message", e.toString());
1444
-            sendEvent(getReactApplicationContext(), "onError", err);
1444
+            sendEvent(getReactApplicationContext(), "error", err);
1445 1445
         }
1446 1446
     }
1447 1447
 
@@ -1494,7 +1494,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1494 1494
             WritableMap err = Arguments.createMap();
1495 1495
             err.putBoolean("success", false);
1496 1496
             err.putString("message", e.toString());
1497
-            sendEvent(getReactApplicationContext(), "onError", err);
1497
+            sendEvent(getReactApplicationContext(), "error", err);
1498 1498
         }
1499 1499
     }
1500 1500
 
@@ -1507,7 +1507,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1507 1507
             WritableMap err = Arguments.createMap();
1508 1508
             err.putBoolean("success", false);
1509 1509
             err.putString("message", e.toString());
1510
-            sendEvent(getReactApplicationContext(), "onError", err);
1510
+            sendEvent(getReactApplicationContext(), "error", err);
1511 1511
         }
1512 1512
     }
1513 1513
 
@@ -1520,7 +1520,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1520 1520
             WritableMap err = Arguments.createMap();
1521 1521
             err.putBoolean("success", false);
1522 1522
             err.putString("message", e.toString());
1523
-            sendEvent(getReactApplicationContext(), "onError", err);
1523
+            sendEvent(getReactApplicationContext(), "error", err);
1524 1524
         }
1525 1525
     }
1526 1526
 
@@ -1533,7 +1533,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1533 1533
             WritableMap err = Arguments.createMap();
1534 1534
             err.putBoolean("success", false);
1535 1535
             err.putString("message", e.toString());
1536
-            sendEvent(getReactApplicationContext(), "onError", err);
1536
+            sendEvent(getReactApplicationContext(), "error", err);
1537 1537
         }
1538 1538
     }
1539 1539
 
@@ -1546,7 +1546,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1546 1546
             WritableMap err = Arguments.createMap();
1547 1547
             err.putBoolean("success", false);
1548 1548
             err.putString("message", e.toString());
1549
-            sendEvent(getReactApplicationContext(), "onError", err);
1549
+            sendEvent(getReactApplicationContext(), "error", err);
1550 1550
         }
1551 1551
     }
1552 1552
 
@@ -1564,7 +1564,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1564 1564
             WritableMap err = Arguments.createMap();
1565 1565
             err.putBoolean("success", false);
1566 1566
             err.putString("message", e.toString());
1567
-            sendEvent(getReactApplicationContext(), "onError", err);
1567
+            sendEvent(getReactApplicationContext(), "error", err);
1568 1568
         }
1569 1569
     }
1570 1570
 
@@ -1577,7 +1577,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1577 1577
             WritableMap err = Arguments.createMap();
1578 1578
             err.putBoolean("success", false);
1579 1579
             err.putString("message", e.toString());
1580
-            sendEvent(getReactApplicationContext(), "onError", err);
1580
+            sendEvent(getReactApplicationContext(), "error", err);
1581 1581
         }
1582 1582
     }
1583 1583
 
@@ -1590,7 +1590,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1590 1590
             WritableMap err = Arguments.createMap();
1591 1591
             err.putBoolean("success", false);
1592 1592
             err.putString("message", e.toString());
1593
-            sendEvent(getReactApplicationContext(), "onError", err);
1593
+            sendEvent(getReactApplicationContext(), "error", err);
1594 1594
         }
1595 1595
     }
1596 1596
 
@@ -1603,7 +1603,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1603 1603
             WritableMap err = Arguments.createMap();
1604 1604
             err.putBoolean("success", false);
1605 1605
             err.putString("message", e.toString());
1606
-            sendEvent(getReactApplicationContext(), "onError", err);
1606
+            sendEvent(getReactApplicationContext(), "error", err);
1607 1607
         }
1608 1608
     }
1609 1609
 
@@ -1616,7 +1616,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1616 1616
             WritableMap err = Arguments.createMap();
1617 1617
             err.putBoolean("success", false);
1618 1618
             err.putString("message", e.toString());
1619
-            sendEvent(getReactApplicationContext(), "onError", err);
1619
+            sendEvent(getReactApplicationContext(), "error", err);
1620 1620
         }
1621 1621
     }
1622 1622
 
@@ -1629,7 +1629,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1629 1629
             WritableMap err = Arguments.createMap();
1630 1630
             err.putBoolean("success", false);
1631 1631
             err.putString("message", e.toString());
1632
-            sendEvent(getReactApplicationContext(), "onError", err);
1632
+            sendEvent(getReactApplicationContext(), "error", err);
1633 1633
         }
1634 1634
     }
1635 1635
 
@@ -1642,7 +1642,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1642 1642
             WritableMap err = Arguments.createMap();
1643 1643
             err.putBoolean("success", false);
1644 1644
             err.putString("message", e.toString());
1645
-            sendEvent(getReactApplicationContext(), "onError", err);
1645
+            sendEvent(getReactApplicationContext(), "error", err);
1646 1646
         }
1647 1647
     }
1648 1648
 
@@ -2176,7 +2176,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
2176 2176
             WritableMap err = Arguments.createMap();
2177 2177
             err.putBoolean("success", false);
2178 2178
             err.putString("message", e.toString());
2179
-            sendEvent(getReactApplicationContext(), "onError", err);
2179
+            sendEvent(getReactApplicationContext(), "error", err);
2180 2180
         }
2181 2181
     }
2182 2182
 

+ 59
- 59
ios/RCTAgora/AgoraConst.h View File

@@ -10,73 +10,73 @@
10 10
 
11 11
 static NSString *RCTAgoraErrorDomain = @"RCTAgoraErrorDomain";
12 12
 
13
-static NSString *DidOccurWarning = @"onWarning";
14
-static NSString *DidOccurError = @"onError";
15
-static NSString *DidApiCallExecute = @"onApiCallExecute";
16
-static NSString *DidJoinChannel = @"onJoinChannelSuccess";
17
-static NSString *DidRejoinChannel = @"onRejoinChannelSuccess";
18
-static NSString *DidLeaveChannel = @"onLeaveChannel";
19
-static NSString *DidClientRoleChanged = @"onClientRoleChanged";
20
-static NSString *DidJoinedOfUid = @"onUserJoined";
21
-static NSString *DidOfflineOfUid = @"onUserOffline";
22
-static NSString *ConnectionChangedToState = @"onConnectionStateChanged";
23
-static NSString *ConnectionDidLost = @"onConnectionLost";
24
-static NSString *TokenPrivilegeWillExpire = @"onTokenPrivilegeWillExpire";
25
-static NSString *RequestToken = @"onRequestToken";
26
-
27
-static NSString *DidMicrophoneEnabled = @"onMicrophoneEnabled";
28
-static NSString *ReportAudioVolumeIndicationOfSpeakers = @"onAudioVolumeIndication";
29
-static NSString *ActiveSpeaker = @"onActiveSpeaker";
30
-static NSString *FirstLocalAudioFrame = @"onFirstLocalAudioFrame";
31
-static NSString *FirstRemoteAudioFrameOfUid = @"onFirstRemoteAudioFrame";
32
-static NSString *VideoDidStop = @"onVideoStopped";
33
-static NSString *FirstLocalVideoFrameWithSize = @"onFirstLocalVideoFrame";
34
-static NSString *FirstRemoteVideoDecodedOfUid = @"onFirstRemoteVideoDecoded";
35
-static NSString *FirstRemoteVideoFrameOfUid = @"onFirstRemoteVideoFrame";
36
-static NSString *DidAudioMuted = @"onUserMuteAudio";
37
-static NSString *DidVideoMuted = @"onUserMuteVideo";
38
-static NSString *DidVideoEnabled = @"onUserEnableVideo";
39
-static NSString *DidLocalVideoEnabled = @"onUserEnableLocalVideo";
40
-static NSString *VideoSizeChangedOfUid = @"onVideoSizeChanged";
41
-static NSString *RemoteVideoStateChangedOfUid = @"onRemoteVideoStateChanged";
42
-static NSString *DidLocalPublishFallbackToAudioOnly = @"onLocalPublishFallbackToAudioOnly";
43
-static NSString *DidRemoteSubscribeFallbackToAudioOnly = @"onRemoteSubscribeFallbackToAudioOnly";
44
-
45
-static NSString *DeviceTypeStateChanged = @"onDeviceTypeStateChanged";
46
-static NSString *DidAudioRouteChanged = @"onAudioRouteChanged";
47
-static NSString *CameraDidReady = @"onCameraReady";
48
-static NSString *CameraFocusDidChangedToRect = @"onCameraFocusAreaChanged";
49
-static NSString *CameraExposureDidChangedToRect = @"onCameraExposureAreaChanged";
50
-
51
-static NSString *ReportRtcStats = @"onRtcStats";
52
-static NSString *LastmileQuality = @"onLastmileQuality";
53
-static NSString *NetworkQuality = @"onNetworkQuality";
54
-static NSString *LocalVideoStats = @"onLocalVideoStats";
55
-static NSString *RemoteVideoStats = @"onRemoteVideoStats";
56
-static NSString *RemoteAudioStats = @"onRemoteAudioStats";
13
+static NSString *DidOccurWarning = @"warning";
14
+static NSString *DidOccurError = @"error";
15
+static NSString *DidApiCallExecute = @"apiCallExecute";
16
+static NSString *DidJoinChannel = @"joinChannelSuccess";
17
+static NSString *DidRejoinChannel = @"rejoinChannelSuccess";
18
+static NSString *DidLeaveChannel = @"leaveChannel";
19
+static NSString *DidClientRoleChanged = @"clientRoleChanged";
20
+static NSString *DidJoinedOfUid = @"userJoined";
21
+static NSString *DidOfflineOfUid = @"userOffline";
22
+static NSString *ConnectionChangedToState = @"connectionStateChanged";
23
+static NSString *ConnectionDidLost = @"connectionLost";
24
+static NSString *TokenPrivilegeWillExpire = @"tokenPrivilegeWillExpire";
25
+static NSString *RequestToken = @"requestToken";
26
+
27
+static NSString *DidMicrophoneEnabled = @"microphoneEnabled";
28
+static NSString *ReportAudioVolumeIndicationOfSpeakers = @"audioVolumeIndication";
29
+static NSString *ActiveSpeaker = @"activeSpeaker";
30
+static NSString *FirstLocalAudioFrame = @"firstLocalAudioFrame";
31
+static NSString *FirstRemoteAudioFrameOfUid = @"firstRemoteAudioFrame";
32
+static NSString *VideoDidStop = @"videoStopped";
33
+static NSString *FirstLocalVideoFrameWithSize = @"firstLocalVideoFrame";
34
+static NSString *FirstRemoteVideoDecodedOfUid = @"firstRemoteVideoDecoded";
35
+static NSString *FirstRemoteVideoFrameOfUid = @"firstRemoteVideoFrame";
36
+static NSString *DidAudioMuted = @"userMuteAudio";
37
+static NSString *DidVideoMuted = @"userMuteVideo";
38
+static NSString *DidVideoEnabled = @"userEnableVideo";
39
+static NSString *DidLocalVideoEnabled = @"userEnableLocalVideo";
40
+static NSString *VideoSizeChangedOfUid = @"videoSizeChanged";
41
+static NSString *RemoteVideoStateChangedOfUid = @"remoteVideoStateChanged";
42
+static NSString *DidLocalPublishFallbackToAudioOnly = @"localPublishFallbackToAudioOnly";
43
+static NSString *DidRemoteSubscribeFallbackToAudioOnly = @"remoteSubscribeFallbackToAudioOnly";
44
+
45
+static NSString *DeviceTypeStateChanged = @"deviceTypeStateChanged";
46
+static NSString *DidAudioRouteChanged = @"audioRouteChanged";
47
+static NSString *CameraDidReady = @"cameraReady";
48
+static NSString *CameraFocusDidChangedToRect = @"cameraFocusAreaChanged";
49
+static NSString *CameraExposureDidChangedToRect = @"cameraExposureAreaChanged";
50
+
51
+static NSString *ReportRtcStats = @"rtcStats";
52
+static NSString *LastmileQuality = @"lastmileQuality";
53
+static NSString *NetworkQuality = @"networkQuality";
54
+static NSString *LocalVideoStats = @"localVideoStats";
55
+static NSString *RemoteVideoStats = @"remoteVideoStats";
56
+static NSString *RemoteAudioStats = @"remoteAudioStats";
57 57
 static NSString *AudioTransportStatsOfUid = @"AudioTransportStatsOfUid";
58 58
 static NSString *VideoTransportStatsOfUid = @"VideoTransportStatsOfUid";
59 59
 
60
-static NSString *LocalAudioMixingDidFinish = @"onLocalAudioMixingFinish";
61
-static NSString *RemoteAudioMixingDidStart = @"onRemoteAudioMixingStart";
62
-static NSString *RemoteAudioMixingDidFinish = @"onRemoteAudioMixingFinish";
63
-static NSString *DidAudioEffectFinish = @"onAudioEffectFinish";
60
+static NSString *LocalAudioMixingDidFinish = @"localAudioMixingFinish";
61
+static NSString *RemoteAudioMixingDidStart = @"remoteAudioMixingStart";
62
+static NSString *RemoteAudioMixingDidFinish = @"remoteAudioMixingFinish";
63
+static NSString *DidAudioEffectFinish = @"audioEffectFinish";
64 64
 
65
-static NSString *StreamPublished = @"onStreamPublished";
66
-static NSString *StreamUnpublish = @"onStreamUnpublish";
67
-static NSString *TranscodingUpdated = @"onTranscodingUpdate";
65
+static NSString *StreamPublished = @"streamPublished";
66
+static NSString *StreamUnpublish = @"streamUnpublish";
67
+static NSString *TranscodingUpdated = @"transcodingUpdate";
68 68
 
69
-static NSString *StreamInjectedStatus = @"onStreamInjectedStatus";
69
+static NSString *StreamInjectedStatus = @"streamInjectedStatus";
70 70
 
71
-static NSString *ReceiveStreamMessage = @"onReceiveStreamMessage";
72
-static NSString *DidOccurStreamMessageError = @"onOccurStreamMessageError";
71
+static NSString *ReceiveStreamMessage = @"receiveStreamMessage";
72
+static NSString *DidOccurStreamMessageError = @"occurStreamMessageError";
73 73
 
74
-static NSString *MediaEngineDidLoaded = @"onMediaEngineLoaded";
75
-static NSString *MediaEngineDidStartCall = @"onMediaEngineStartCall";
74
+static NSString *MediaEngineDidLoaded = @"mediaEngineLoaded";
75
+static NSString *MediaEngineDidStartCall = @"mediaEngineStartCall";
76 76
 
77
-static NSString *ConnectionDidInterrupted = @"onConnectionInterrupted";
78
-static NSString *ConnectionDidBanned = @"onConnectionBanned";
79
-static NSString *AudioQualityOfUid = @"onAudioQuality";
77
+static NSString *ConnectionDidInterrupted = @"connectionInterrupted";
78
+static NSString *ConnectionDidBanned = @"connectionBanned";
79
+static NSString *AudioQualityOfUid = @"audioQuality";
80 80
 
81 81
 @interface AgoraConst : NSObject
82 82
 

+ 31
- 283
lib/RtcEngine.native.js View File

@@ -6,16 +6,14 @@ const AgoraEventEmitter = new react_native_1.NativeEventEmitter(Agora);
6 6
 /**
7 7
  * @class RtcEngine
8 8
  */
9
-class RtcEngine {
9
+const RtcEngine = Object.assign({}, Agora, { eventTypes: new Set(), 
10 10
     /**
11
-     * init AgoraRtcEngine
11
+     * init agora rtc engine and begin subscribe event immediately
12 12
      * @param options: Option
13 13
      */
14
-    static init(options) {
15
-        this.removeEmitter();
14
+    init(options) {
16 15
         Agora.init(options);
17
-        this.listeners = [];
18
-    }
16
+    },
19 17
     /**
20 18
      * join channel
21 19
      * @param channelName String for channel name
@@ -24,298 +22,48 @@ class RtcEngine {
24 22
      * @param info Object extra info
25 23
      * @return Promise
26 24
      */
27
-    static joinChannel(channelName, uid, token, info) {
25
+    joinChannel(channelName, uid, token, info) {
28 26
         return Agora.joinChannel({ channelName, uid, token, info });
29
-    }
27
+    },
30 28
     /**
31
-     * RtcEngine events register
32
-     * @param eventScheduler EventScheduler
29
+     * on - add event listener for react native event
30
+     * @param eventType String
31
+     * @param eventHandler Function
33 32
      */
34
-    static eventEmitter(eventScheduler) {
35
-        this.removeEmitter();
36
-        // const events = EventSchedulerKeys;
37
-        const events = [
38
-            "onWarning",
39
-            "onError",
40
-            "onJoinChannelSuccess",
41
-            "onRejoinChannelSuccess",
42
-            "onLeaveChannel",
43
-            "onClientRoleChanged",
44
-            "onUserJoined",
45
-            "onUserOffline",
46
-            "onConnectionStateChanged",
47
-            "onConnectionInterrupted",
48
-            "onConnectionLost",
49
-            "onConnectionBanned",
50
-            "onApiCallExecuted",
51
-            "onTokenPrivilegeWillExpire",
52
-            "onRequestToken",
53
-            "onMicrophoneEnabled",
54
-            "onAudioVolumeIndication",
55
-            "onActiveSpeaker",
56
-            "onFirstLocalAudioFrame",
57
-            "onFirstRemoteAudioFrame",
58
-            "onVideoStopped",
59
-            "onFirstLocalVideoFrame",
60
-            "onFirstRemoteVideoDecoded",
61
-            "onFirstRemoteVideoFrame",
62
-            "onUserMuteAudio",
63
-            "onUserMuteVideo",
64
-            "onUserEnableVideo",
65
-            "onUserEnableLocalVideo",
66
-            "onVideoSizeChanged",
67
-            "onRemoteVideoStateChanged",
68
-            "onLocalPublishFallbackToAudioOnly",
69
-            "onRemoteSubscribeFallbackToAudioOnly",
70
-            "onAudioRouteChanged",
71
-            "onCameraReady",
72
-            "onCameraFocusAreaChanged",
73
-            "onCameraExposureAreaChanged",
74
-            "onAudioQuality",
75
-            "onRtcStats",
76
-            "onLastmileQuality",
77
-            "onNetworkQuality",
78
-            "onLocalVideoStats",
79
-            "onRemoteVideoStats",
80
-            "onRemoteAudioStats",
81
-            "onLocalVideoStat",
82
-            "onRemoteVideoStat",
83
-            "onRemoteAudioTransportStats",
84
-            "onRemoteVideoTransportStats",
85
-            "onAudioMixingFinished",
86
-            "onAudioEffectFinished",
87
-            "onStreamPublished",
88
-            "onStreamUnpublished",
89
-            "onTranscodingUpdated",
90
-            "onStreamInjectedStatus",
91
-            "onStreamMessage",
92
-            "onStreamMessageError",
93
-            "onMediaEngineLoadSuccess",
94
-            "onMediaEngineStartCallSuccess",
95
-        ];
96
-        for (let event of events) {
97
-            const functor = eventScheduler[event];
98
-            if (functor) {
99
-                this.listeners.push(AgoraEventEmitter.addListener(event, msg => {
100
-                    functor(msg);
101
-                }));
102
-            }
103
-        }
104
-    }
105
-    /**
106
-     * remove emitter
107
-     */
108
-    static removeEmitter() {
109
-        if (this.listeners && this.listeners.length > 0) {
110
-            for (let listener of this.listeners) {
111
-                listener.remove();
112
-                this.listeners = [];
113
-            }
114
-        }
115
-    }
33
+    on(eventType, listener) {
34
+        this.eventTypes.add(eventType);
35
+        AgoraEventEmitter.addListener(eventType, listener);
36
+    },
116 37
     /**
117
-     * enableLastmileTest
118
-     * @return Promise
38
+     * off - remove event listener for react native event
39
+     * @param eventType
40
+     * @param listener
119 41
      */
120
-    static enableLastmileTest() {
121
-        return Agora.enableLastmileTest();
122
-    }
42
+    off(eventType) {
43
+        AgoraEventEmitter.removeAllListeners(eventType);
44
+        this.eventTypes.delete(eventType);
45
+    },
123 46
     /**
124
-     * disableLastmileTest
125
-     * @return Promise
47
+     * removeAllListeners
126 48
      */
127
-    static disableLastmileTest() {
128
-        return Agora.disableLastmileTest();
129
-    }
130
-    /**
131
-     * leaveChannel
132
-     * @return Promise
133
-     */
134
-    static leaveChannel() {
135
-        return Agora.leaveChannel();
136
-    }
49
+    removeAllListeners() {
50
+        for (let eventType of this.eventTypes) {
51
+            this.off(eventType);
52
+        }
53
+        this.eventTypes.clear();
54
+    },
137 55
     /**
138 56
      * destroy AgoraRtcEngine
139 57
      */
140
-    static destroy() {
58
+    destroy() {
141 59
         Agora.destroy();
142
-    }
143
-    /**
144
-     * setupLocalVideo
145
-     * @param options: VideoOption
146
-     */
147
-    static setupLocalVideo(options) {
148
-        Agora.setupLocalVideo(options);
149
-    }
150
-    /**
151
-     * setupRemoteVideo
152
-     * @param options: VideoOption
153
-     */
154
-    static setupRemoteVideo(options) {
155
-        Agora.setupRemoteVideo(options);
156
-    }
157
-    /**
158
-     * start AgoraRtcEngine preview
159
-     */
160
-    static startPreview() {
161
-        Agora.startPreview();
162
-    }
163
-    /**
164
-     * stop AgoraRtcEngine preview
165
-     */
166
-    static stopPreview() {
167
-        Agora.stopPreview();
168
-    }
169
-    /**
170
-     * start live trancoding
171
-     * @param options LiveTranscoding
172
-     */
173
-    static setLiveTranscoding(options) {
174
-        Agora.setLiveTranscoding(options);
175
-    }
176
-    /**
177
-     * setLocalRenderMode
178
-     * @param mode Number
179
-     */
180
-    static setLocalRenderMode(mode) {
181
-        Agora.setLocalRenderMode(mode);
182
-    }
183
-    /**
184
-     * setRemoteRenderMode
185
-     * @param uid Number
186
-     * @param mode Number
187
-     */
188
-    static setRemoteRenderMode(uid, mode) {
189
-        Agora.setRemoteRenderMode(uid, mode);
190
-    }
191
-    /**
192
-     * enableAudioVolumeIndication
193
-     * @param interval Number
194
-     * @param smooth Number
195
-     */
196
-    static enableAudioVolumeIndication(interval, smooth) {
197
-        Agora.enableAudioVolumeIndication(interval, smooth);
198
-    }
199
-    /**
200
-     * switch camera
201
-     * @return Promise
202
-     */
203
-    static switchCamera() {
204
-        return Agora.switchCamera();
205
-    }
206
-    static enableVideo() {
207
-        Agora.enableVideo();
208
-    }
209
-    static disableVideo() {
210
-        Agora.disableVideo();
211
-    }
212
-    /**
213
-     * setEnableSpeakerphone
214
-     * @param status Boolena
215
-     */
216
-    static setEnableSpeakerphone(status) {
217
-        Agora.setEnableSpeakerphone(status);
218
-    }
219
-    /**
220
-     * muteLocalAudioStream
221
-     * @param status Boolena
222
-     */
223
-    static muteLocalAudioStream(status) {
224
-        Agora.muteLocalAudioStream(status);
225
-    }
226
-    /**
227
-     * muteRemoteAudioStream
228
-     * @param uid Number
229
-     * @param status Boolean
230
-     */
231
-    static muteRemoteAudioStream(uid, status) {
232
-        Agora.muteRemoteAudioStream(uid, status);
233
-    }
234
-    /**
235
-     * muteAllRemoteAudioStreams
236
-     * @param status Boolean
237
-     */
238
-    static muteAllRemoteAudioStreams(status) {
239
-        Agora.muteAllRemoteAudioStreams(status);
240
-    }
241
-    /**
242
-     * setCameraTorchOn
243
-     * @param status Boolean
244
-     * @return Promise
245
-     */
246
-    static setCameraTorchOn(status) {
247
-        return Agora.setCameraTorchOn(status);
248
-    }
249
-    /**
250
-     * setCameraAutoFocusFaceModeEnabled
251
-     * @param status Boolean
252
-     * @return Promise
253
-     */
254
-    static setCameraAutoFocusFaceModeEnabled(status) {
255
-        return Agora.setCameraAutoFocusFaceModeEnabled(status);
256
-    }
257
-    /**
258
-     * setDefaultAudioRouteToSpeakerphone
259
-     * @param status Boolean
260
-     * @return Promise
261
-     */
262
-    static setDefaultAudioRouteToSpeakerphone(status) {
263
-        Agora.setDefaultAudioRouteToSpeakerphone(status);
264
-    }
265
-    /**
266
-     * muteLocalVideoStream
267
-     * @param status Boolean
268
-     */
269
-    static muteLocalVideoStream(status) {
270
-        Agora.muteLocalVideoStream(status);
271
-    }
272
-    /**
273
-     * enableLocalVideo
274
-     * @param status Boolean
275
-     */
276
-    static enableLocalVideo(status) {
277
-        Agora.enableLocalVideo(status);
278
-    }
279
-    /**
280
-     * muteAllRemoteVideoStreams
281
-     * @param status Boolean
282
-     */
283
-    static muteAllRemoteVideoStreams(status) {
284
-        Agora.muteAllRemoteVideoStreams(status);
285
-    }
286
-    /**
287
-     * muteRemoteVideoStream
288
-     * @param status Boolean
289
-     */
290
-    static muteRemoteVideoStream(uid, status) {
291
-        Agora.muteRemoteVideoStream(uid, status);
292
-    }
293
-    /**
294
-     * createDataStream
295
-     * @param reliable Boolean
296
-     * @param ordered Boolean
297
-     * @return Promise
298
-     */
299
-    static createDataStream(reliable, ordered) {
300
-        return Agora.createDataStream({ reliable, ordered });
301
-    }
302
-    /**
303
-     * sendStreamMessage
304
-     * @param reliable Boolean
305
-     * @param ordered Boolean
306
-     * @return Promise
307
-     */
308
-    static sendStreamMessage(streamId, data) {
309
-        return Agora.sendStreamMessage(streamId, data);
310
-    }
60
+    },
311 61
     /**
312 62
      * getSdkVersion
313 63
      * @param callback Function
314 64
      */
315
-    static getSdkVersion(callback) {
65
+    getSdkVersion(callback) {
316 66
         Agora.getSdkVersion().then(callback);
317
-    }
318
-}
67
+    } });
319 68
 exports.default = RtcEngine;
320
-;
321 69
 //# sourceMappingURL=RtcEngine.native.js.map

+ 1
- 1
lib/RtcEngine.native.js.map View File

@@ -1 +1 @@
1
-{"version":3,"file":"RtcEngine.native.js","sourceRoot":"","sources":["../src/RtcEngine.native.ts"],"names":[],"mappings":"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"}
1
+{"version":3,"file":"RtcEngine.native.js","sourceRoot":"","sources":["../src/RtcEngine.native.ts"],"names":[],"mappings":";;AAAA,+CAGsB;AAQtB,MAAM,EAAE,KAAK,EAAE,GAAG,4BAAa,CAAC;AAChC,MAAM,iBAAiB,GAAG,IAAI,iCAAkB,CAAC,KAAK,CAAC,CAAC;AAExD;;GAEG;AACH,MAAM,SAAS,qBAAQ,KAAK,IACxB,UAAU,EAAE,IAAI,GAAG,EAAE;IACrB;;;OAGG;IACH,IAAI,CAAC,OAAe;QAChB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;IAED;;;;;;;OAOG;IACH,WAAW,CAAC,WAAmB,EAAE,GAAY,EAAE,KAAc,EAAE,IAAa;QACxE,OAAO,KAAK,CAAC,WAAW,CAAC,EAAC,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;IAC9D,CAAC;IAED;;;;OAIG;IACH,EAAE,CAAC,SAAiB,EAAE,QAAiC;QACnD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC/B,iBAAiB,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACvD,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,SAAiB;QACjB,iBAAiB,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,kBAAkB;QACd,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE;YACnC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;SACvB;QACD,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,OAAO;QACH,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;IAED;;;OAGG;IACH,aAAa,CAAC,QAAwB;QAClC,KAAK,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC,GACJ,CAAC;AAEF,kBAAe,SAAS,CAAC"}

+ 0
- 9967
package-lock.json
File diff suppressed because it is too large
View File


+ 7
- 2
samples/simpleDemo/babel.config.js View File

@@ -1,3 +1,8 @@
1 1
 module.exports = {
2
-  presets: ["module:metro-react-native-babel-preset"]
3
-}
2
+  presets: ['module:metro-react-native-babel-preset'],
3
+  env: {
4
+    production: {
5
+      plugins: ['react-native-paper/babel'],
6
+    },
7
+  },
8
+};

+ 41
- 42
samples/simpleDemo/components/agora.js View File

@@ -133,52 +133,49 @@ export default class AgoraComponent extends Component<Props> {
133 133
       clientRole: Host,
134 134
       audioProfile: AudioProfileDefault,
135 135
       audioScenario: AudioScenarioDefault
136
-    }
137
-    console.log("[CONFIG]", JSON.stringify(config));
138
-    console.log("[CONFIG.encoderConfig", config.videoEncoderConfig);
139
-    RtcEngine.init(config);
140
-    RtcEngine.eventEmitter({
141
-      onFirstRemoteVideoDecoded: (data) => {
142
-        console.log('[RtcEngine] onFirstRemoteVideoDecoded', data);
143
-      },
144
-      onUserJoined: (data) => {
145
-        console.log('[RtcEngine] onUserJoined', data);
146
-        const {peerIds} = this.state;
147
-        if (peerIds.indexOf(data.uid) === -1) {
148
-          this.setState({
149
-            peerIds: [...peerIds, data.uid]
150
-          })
151
-        }
152
-      },
153
-      onUserOffline: (data) => {
154
-        console.log('[RtcEngine] onUserOffline', data);
155
-        this.setState({
156
-            peerIds: this.state.peerIds.filter(uid => uid !== data.uid)
157
-        })
158
-      },
159
-      onJoinChannelSuccess: (data) => {
160
-        console.log('[RtcEngine] onJoinChannelSuccess', data);
161
-        RtcEngine.startPreview();
136
+    };
137
+    RtcEngine.on('firstRemoteVideoDecoded', (data) => {
138
+      console.log('[RtcEngine] onFirstRemoteVideoDecoded', data);
139
+    });
140
+    RtcEngine.on('userJoined', (data) => {
141
+      console.log('[RtcEngine] onUserJoined', data);
142
+      const {peerIds} = this.state;
143
+      if (peerIds.indexOf(data.uid) === -1) {
162 144
         this.setState({
163
-          joinSucceed: true
145
+          peerIds: [...peerIds, data.uid]
164 146
         })
165
-      },
166
-      onAudioVolumeIndication: (data) => {
167
-        console.log('[RtcEngine] onAudioVolumeIndication', data);
168
-      },
169
-      onClientRoleChanged: (data) => {
170
-        console.log("[RtcEngine] onClientRoleChanged", data);
171
-      },
172
-      onError: (data) => {
173
-        console.log('[RtcEngine] onError', data);
174
-        if (data.error === 17) {
175
-          RtcEngine.leaveChannel().then(_ => {
176
-            RtcEngine.destroy();
177
-            this.props.onCancel(data);
178
-          });
179
-        }
147
+      }
148
+    });
149
+    RtcEngine.on('userOffline', (data) => {
150
+      console.log('[RtcEngine] onUserOffline', data);
151
+      this.setState({
152
+          peerIds: this.state.peerIds.filter(uid => uid !== data.uid)
153
+      })
154
+    });
155
+    RtcEngine.on('joinChannelSuccess', (data) => {
156
+      console.log('[RtcEngine] onJoinChannelSuccess', data);
157
+      RtcEngine.startPreview();
158
+      this.setState({
159
+        joinSucceed: true
160
+      })
161
+    });
162
+    RtcEngine.on('audioVolumeIndication', (data) => {
163
+      console.log('[RtcEngine] onAudioVolumeIndication', data);
164
+    });
165
+    RtcEngine.on('clientRoleChanged', (data) => {
166
+      console.log("[RtcEngine] onClientRoleChanged", data);
167
+    })
168
+    RtcEngine.on('error', (data) => {
169
+      if (data.error === 17) {
170
+        RtcEngine.leaveChannel().then(_ => {
171
+          RtcEngine.destroy();
172
+          this.props.onCancel(data);
173
+        });
180 174
       }
181 175
     })
176
+    console.log("[CONFIG]", JSON.stringify(config));
177
+    console.log("[CONFIG.encoderConfig", config.videoEncoderConfig);
178
+    RtcEngine.init(config);
182 179
   }
183 180
 
184 181
   componentDidMount () {
@@ -194,12 +191,14 @@ export default class AgoraComponent extends Component<Props> {
194 191
   componentWillUnmount () {
195 192
     if (this.state.joinSucceed) {
196 193
       RtcEngine.leaveChannel();
194
+      RtcEngine.removeAllListeners();
197 195
       RtcEngine.destroy();
198 196
     }
199 197
   }
200 198
 
201 199
   handleCancel = () => {
202 200
     RtcEngine.leaveChannel();
201
+    RtcEngine.removeAllListeners();
203 202
     RtcEngine.destroy();
204 203
     this.props.onCancel();
205 204
   }

+ 4
- 4
samples/simpleDemo/ios/Podfile.lock View File

@@ -2,11 +2,11 @@ PODS:
2 2
   - AgoraRtcEngine_iOS (2.3.3)
3 3
   - React (0.58.3):
4 4
     - React/Core (= 0.58.3)
5
-  - react-native-agora (2.3.3):
5
+  - react-native-agora (2.3.3-alpha.4):
6 6
     - AgoraRtcEngine_iOS (= 2.3.3)
7 7
     - React
8
-    - react-native-agora/AgoraRtcCryptoLoader (= 2.3.3)
9
-  - react-native-agora/AgoraRtcCryptoLoader (2.3.3):
8
+    - react-native-agora/AgoraRtcCryptoLoader (= 2.3.3-alpha.4)
9
+  - react-native-agora/AgoraRtcCryptoLoader (2.3.3-alpha.4):
10 10
     - AgoraRtcEngine_iOS (= 2.3.3)
11 11
     - React
12 12
   - React/Core (0.58.3):
@@ -33,7 +33,7 @@ EXTERNAL SOURCES:
33 33
 SPEC CHECKSUMS:
34 34
   AgoraRtcEngine_iOS: 8ad4b58dafed2cec5df03fa1f0ddbdad2c9ff958
35 35
   React: 9b873b38b92ed8012d7cdf3b965477095ed364c4
36
-  react-native-agora: ad538661771e745fac8920412002e0e90903bbc8
36
+  react-native-agora: 749ff4aadd5c8125139c82787c378de7e304805d
37 37
   yoga: 0885622311729a02c2bc02dca97167787a51488b
38 38
 
39 39
 PODFILE CHECKSUM: 20565f1fb8643e49a8e76b33da6bb4e2d188134a

+ 71
- 71
samples/simpleDemo/ios/simpleDemo.xcodeproj/project.pbxproj View File

@@ -13,6 +13,7 @@
13 13
 		00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; };
14 14
 		00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; };
15 15
 		00E356F31AD99517003FC87E /* simpleDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* simpleDemoTests.m */; };
16
+		068EAAC85996A1A5C8217EAB /* libPods-simpleDemoTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 951159A5104BF2D9AAB23983 /* libPods-simpleDemoTests.a */; };
16 17
 		0842E3912206D315003875AC /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 0842E36A2206D315003875AC /* libc++.tbd */; };
17 18
 		0842E3932206D31B003875AC /* libresolv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 0842E3922206D31B003875AC /* libresolv.tbd */; };
18 19
 		0842E3952206D320003875AC /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0842E3942206D320003875AC /* AVFoundation.framework */; };
@@ -45,13 +46,12 @@
45 46
 		2D16E6881FA4F8E400B85C8A /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2D16E6891FA4F8E400B85C8A /* libReact.a */; };
46 47
 		2DCD954D1E0B4F2C00145EB5 /* simpleDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* simpleDemoTests.m */; };
47 48
 		2DF0FFEE2056DD460020B375 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3EA31DF850E9000B6D8A /* libReact.a */; };
48
-		4D3FC919BA1ACFBD0D0EC6A1 /* libPods-simpleDemoTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ED1D799E3903895175F184F1 /* libPods-simpleDemoTests.a */; };
49
-		56F0265FA18A3B1951F48621 /* libPods-simpleDemo-tvOSTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7A85F37D8B40BE09C0F39D31 /* libPods-simpleDemo-tvOSTests.a */; };
49
+		3752A059FBE8E09075DA4AE1 /* libPods-simpleDemo-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 370F79B8FF06A30AC0F9C3B5 /* libPods-simpleDemo-tvOS.a */; };
50
+		6793190DE86DEFCF49576B2B /* libPods-simpleDemo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5C46FE5A2E9627977A3B13E9 /* libPods-simpleDemo.a */; };
50 51
 		832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
51 52
 		ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */; };
52
-		C3E022B94502A91EB1E0372C /* libPods-simpleDemo-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 299FC751E168E658B289864A /* libPods-simpleDemo-tvOS.a */; };
53
-		EC90B755EAB038945B70EFF8 /* libPods-simpleDemo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 66BD8A39FC5EF1269D9EF1A2 /* libPods-simpleDemo.a */; };
54 53
 		ED297163215061F000B7C4FE /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED297162215061F000B7C4FE /* JavaScriptCore.framework */; };
54
+		F36C97402B4845BDA6A2844C /* libPods-simpleDemo-tvOSTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F05F2972B345118AE7DEBA00 /* libPods-simpleDemo-tvOSTests.a */; };
55 55
 /* End PBXBuildFile section */
56 56
 
57 57
 /* Begin PBXContainerItemProxy section */
@@ -347,6 +347,7 @@
347 347
 		00E356EE1AD99517003FC87E /* simpleDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = simpleDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
348 348
 		00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
349 349
 		00E356F21AD99517003FC87E /* simpleDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = simpleDemoTests.m; sourceTree = "<group>"; };
350
+		03E6606B86246B0AE5C5BFC5 /* Pods-simpleDemo-tvOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemo-tvOSTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemo-tvOSTests/Pods-simpleDemo-tvOSTests.release.xcconfig"; sourceTree = "<group>"; };
350 351
 		0842E36A2206D315003875AC /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; };
351 352
 		0842E3922206D31B003875AC /* libresolv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = usr/lib/libresolv.tbd; sourceTree = SDKROOT; };
352 353
 		0842E3942206D320003875AC /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
@@ -369,26 +370,25 @@
369 370
 		13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = simpleDemo/Info.plist; sourceTree = "<group>"; };
370 371
 		13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = simpleDemo/main.m; sourceTree = "<group>"; };
371 372
 		146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
372
-		2518E82A5EEFEBCCB546686E /* Pods-simpleDemoTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemoTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemoTests/Pods-simpleDemoTests.debug.xcconfig"; sourceTree = "<group>"; };
373
-		299FC751E168E658B289864A /* libPods-simpleDemo-tvOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-simpleDemo-tvOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
373
+		2C28A102506C6EC8AEEADEBB /* Pods-simpleDemoTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemoTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemoTests/Pods-simpleDemoTests.release.xcconfig"; sourceTree = "<group>"; };
374 374
 		2D02E47B1E0B4A5D006451C7 /* simpleDemo-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "simpleDemo-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
375 375
 		2D02E4901E0B4A5D006451C7 /* simpleDemo-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "simpleDemo-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
376 376
 		2D16E6891FA4F8E400B85C8A /* libReact.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libReact.a; sourceTree = BUILT_PRODUCTS_DIR; };
377
-		425DC21FE0AD7CF5497EBBAD /* Pods-simpleDemo-tvOSTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemo-tvOSTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemo-tvOSTests/Pods-simpleDemo-tvOSTests.debug.xcconfig"; sourceTree = "<group>"; };
378
-		45C3C66C498C5DD68AEA83DB /* Pods-simpleDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemo/Pods-simpleDemo.debug.xcconfig"; sourceTree = "<group>"; };
379
-		49AF4131548CCDDCC8317F3A /* Pods-simpleDemo-tvOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemo-tvOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemo-tvOS/Pods-simpleDemo-tvOS.release.xcconfig"; sourceTree = "<group>"; };
380
-		55F01DA43729E829E7920BE2 /* Pods-simpleDemo-tvOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemo-tvOSTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemo-tvOSTests/Pods-simpleDemo-tvOSTests.release.xcconfig"; sourceTree = "<group>"; };
381
-		5B50FE91740B45AD2B2FFA43 /* Pods-simpleDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemo/Pods-simpleDemo.release.xcconfig"; sourceTree = "<group>"; };
377
+		370F79B8FF06A30AC0F9C3B5 /* libPods-simpleDemo-tvOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-simpleDemo-tvOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
378
+		3FE905B2466BFABBAA8F09A8 /* Pods-simpleDemo-tvOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemo-tvOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemo-tvOS/Pods-simpleDemo-tvOS.release.xcconfig"; sourceTree = "<group>"; };
379
+		4562E79007DAB0C0D6F958BC /* Pods-simpleDemo-tvOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemo-tvOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemo-tvOS/Pods-simpleDemo-tvOS.debug.xcconfig"; sourceTree = "<group>"; };
380
+		5C46FE5A2E9627977A3B13E9 /* libPods-simpleDemo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-simpleDemo.a"; sourceTree = BUILT_PRODUCTS_DIR; };
382 381
 		5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
383
-		66BD8A39FC5EF1269D9EF1A2 /* libPods-simpleDemo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-simpleDemo.a"; sourceTree = BUILT_PRODUCTS_DIR; };
384
-		670CBBAFD05743865934B941 /* Pods-simpleDemo-tvOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemo-tvOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemo-tvOS/Pods-simpleDemo-tvOS.debug.xcconfig"; sourceTree = "<group>"; };
382
+		61D6128EB7E59612F733FF02 /* Pods-simpleDemoTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemoTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemoTests/Pods-simpleDemoTests.debug.xcconfig"; sourceTree = "<group>"; };
385 383
 		78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
386
-		7A85F37D8B40BE09C0F39D31 /* libPods-simpleDemo-tvOSTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-simpleDemo-tvOSTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
387 384
 		832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
385
+		951159A5104BF2D9AAB23983 /* libPods-simpleDemoTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-simpleDemoTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
388 386
 		ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTBlob.xcodeproj; path = "../node_modules/react-native/Libraries/Blob/RCTBlob.xcodeproj"; sourceTree = "<group>"; };
389
-		B3CA7DAF4D391036EC75502F /* Pods-simpleDemoTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemoTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemoTests/Pods-simpleDemoTests.release.xcconfig"; sourceTree = "<group>"; };
390
-		ED1D799E3903895175F184F1 /* libPods-simpleDemoTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-simpleDemoTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
387
+		B8C83FE8120F5A8CA66DC95D /* Pods-simpleDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemo/Pods-simpleDemo.debug.xcconfig"; sourceTree = "<group>"; };
388
+		D411D46516249CACE14D41DC /* Pods-simpleDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemo/Pods-simpleDemo.release.xcconfig"; sourceTree = "<group>"; };
389
+		DCFC59650767B9DD307D635F /* Pods-simpleDemo-tvOSTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-simpleDemo-tvOSTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-simpleDemo-tvOSTests/Pods-simpleDemo-tvOSTests.debug.xcconfig"; sourceTree = "<group>"; };
391 390
 		ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
391
+		F05F2972B345118AE7DEBA00 /* libPods-simpleDemo-tvOSTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-simpleDemo-tvOSTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
392 392
 /* End PBXFileReference section */
393 393
 
394 394
 /* Begin PBXFrameworksBuildPhase section */
@@ -397,7 +397,7 @@
397 397
 			buildActionMask = 2147483647;
398 398
 			files = (
399 399
 				140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */,
400
-				4D3FC919BA1ACFBD0D0EC6A1 /* libPods-simpleDemoTests.a in Frameworks */,
400
+				068EAAC85996A1A5C8217EAB /* libPods-simpleDemoTests.a in Frameworks */,
401 401
 			);
402 402
 			runOnlyForDeploymentPostprocessing = 0;
403 403
 		};
@@ -427,7 +427,7 @@
427 427
 				832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
428 428
 				00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
429 429
 				139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
430
-				EC90B755EAB038945B70EFF8 /* libPods-simpleDemo.a in Frameworks */,
430
+				6793190DE86DEFCF49576B2B /* libPods-simpleDemo.a in Frameworks */,
431 431
 			);
432 432
 			runOnlyForDeploymentPostprocessing = 0;
433 433
 		};
@@ -443,7 +443,7 @@
443 443
 				2D02E4C61E0B4AEC006451C7 /* libRCTSettings-tvOS.a in Frameworks */,
444 444
 				2D02E4C71E0B4AEC006451C7 /* libRCTText-tvOS.a in Frameworks */,
445 445
 				2D02E4C81E0B4AEC006451C7 /* libRCTWebSocket-tvOS.a in Frameworks */,
446
-				C3E022B94502A91EB1E0372C /* libPods-simpleDemo-tvOS.a in Frameworks */,
446
+				3752A059FBE8E09075DA4AE1 /* libPods-simpleDemo-tvOS.a in Frameworks */,
447 447
 			);
448 448
 			runOnlyForDeploymentPostprocessing = 0;
449 449
 		};
@@ -452,7 +452,7 @@
452 452
 			buildActionMask = 2147483647;
453 453
 			files = (
454 454
 				2DF0FFEE2056DD460020B375 /* libReact.a in Frameworks */,
455
-				56F0265FA18A3B1951F48621 /* libPods-simpleDemo-tvOSTests.a in Frameworks */,
455
+				F36C97402B4845BDA6A2844C /* libPods-simpleDemo-tvOSTests.a in Frameworks */,
456 456
 			);
457 457
 			runOnlyForDeploymentPostprocessing = 0;
458 458
 		};
@@ -606,10 +606,10 @@
606 606
 				0842E36A2206D315003875AC /* libc++.tbd */,
607 607
 				ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
608 608
 				2D16E6891FA4F8E400B85C8A /* libReact.a */,
609
-				66BD8A39FC5EF1269D9EF1A2 /* libPods-simpleDemo.a */,
610
-				299FC751E168E658B289864A /* libPods-simpleDemo-tvOS.a */,
611
-				7A85F37D8B40BE09C0F39D31 /* libPods-simpleDemo-tvOSTests.a */,
612
-				ED1D799E3903895175F184F1 /* libPods-simpleDemoTests.a */,
609
+				5C46FE5A2E9627977A3B13E9 /* libPods-simpleDemo.a */,
610
+				370F79B8FF06A30AC0F9C3B5 /* libPods-simpleDemo-tvOS.a */,
611
+				F05F2972B345118AE7DEBA00 /* libPods-simpleDemo-tvOSTests.a */,
612
+				951159A5104BF2D9AAB23983 /* libPods-simpleDemoTests.a */,
613 613
 			);
614 614
 			name = Frameworks;
615 615
 			sourceTree = "<group>";
@@ -623,28 +623,28 @@
623 623
 			name = Products;
624 624
 			sourceTree = "<group>";
625 625
 		};
626
-		6E8B12A295B3F1943001B9D8 /* Pods */ = {
626
+		78C398B11ACF4ADC00677621 /* Products */ = {
627 627
 			isa = PBXGroup;
628 628
 			children = (
629
-				45C3C66C498C5DD68AEA83DB /* Pods-simpleDemo.debug.xcconfig */,
630
-				5B50FE91740B45AD2B2FFA43 /* Pods-simpleDemo.release.xcconfig */,
631
-				670CBBAFD05743865934B941 /* Pods-simpleDemo-tvOS.debug.xcconfig */,
632
-				49AF4131548CCDDCC8317F3A /* Pods-simpleDemo-tvOS.release.xcconfig */,
633
-				425DC21FE0AD7CF5497EBBAD /* Pods-simpleDemo-tvOSTests.debug.xcconfig */,
634
-				55F01DA43729E829E7920BE2 /* Pods-simpleDemo-tvOSTests.release.xcconfig */,
635
-				2518E82A5EEFEBCCB546686E /* Pods-simpleDemoTests.debug.xcconfig */,
636
-				B3CA7DAF4D391036EC75502F /* Pods-simpleDemoTests.release.xcconfig */,
629
+				78C398B91ACF4ADC00677621 /* libRCTLinking.a */,
630
+				3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */,
637 631
 			);
638
-			name = Pods;
632
+			name = Products;
639 633
 			sourceTree = "<group>";
640 634
 		};
641
-		78C398B11ACF4ADC00677621 /* Products */ = {
635
+		7E38130487AE81DA0F050D92 /* Pods */ = {
642 636
 			isa = PBXGroup;
643 637
 			children = (
644
-				78C398B91ACF4ADC00677621 /* libRCTLinking.a */,
645
-				3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */,
638
+				B8C83FE8120F5A8CA66DC95D /* Pods-simpleDemo.debug.xcconfig */,
639
+				D411D46516249CACE14D41DC /* Pods-simpleDemo.release.xcconfig */,
640
+				4562E79007DAB0C0D6F958BC /* Pods-simpleDemo-tvOS.debug.xcconfig */,
641
+				3FE905B2466BFABBAA8F09A8 /* Pods-simpleDemo-tvOS.release.xcconfig */,
642
+				DCFC59650767B9DD307D635F /* Pods-simpleDemo-tvOSTests.debug.xcconfig */,
643
+				03E6606B86246B0AE5C5BFC5 /* Pods-simpleDemo-tvOSTests.release.xcconfig */,
644
+				61D6128EB7E59612F733FF02 /* Pods-simpleDemoTests.debug.xcconfig */,
645
+				2C28A102506C6EC8AEEADEBB /* Pods-simpleDemoTests.release.xcconfig */,
646 646
 			);
647
-			name = Products;
647
+			name = Pods;
648 648
 			sourceTree = "<group>";
649 649
 		};
650 650
 		832341AE1AAA6A7D00B99B32 /* Libraries */ = {
@@ -685,7 +685,7 @@
685 685
 				83CBBA001A601CBA00E9B192 /* Products */,
686 686
 				2D16E6871FA4F8E400B85C8A /* Frameworks */,
687 687
 				0842E3102206D244003875AC /* Recovered References */,
688
-				6E8B12A295B3F1943001B9D8 /* Pods */,
688
+				7E38130487AE81DA0F050D92 /* Pods */,
689 689
 			);
690 690
 			indentWidth = 2;
691 691
 			sourceTree = "<group>";
@@ -719,7 +719,7 @@
719 719
 			isa = PBXNativeTarget;
720 720
 			buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "simpleDemoTests" */;
721 721
 			buildPhases = (
722
-				EAF58240469798C6B16617A5 /* [CP] Check Pods Manifest.lock */,
722
+				4BEA691CDC159330D76026CC /* [CP] Check Pods Manifest.lock */,
723 723
 				00E356EA1AD99517003FC87E /* Sources */,
724 724
 				00E356EB1AD99517003FC87E /* Frameworks */,
725 725
 				00E356EC1AD99517003FC87E /* Resources */,
@@ -738,7 +738,7 @@
738 738
 			isa = PBXNativeTarget;
739 739
 			buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "simpleDemo" */;
740 740
 			buildPhases = (
741
-				BDA8D1EBEEE8A2517BA1F5A7 /* [CP] Check Pods Manifest.lock */,
741
+				3D4AA6A23B06F1B41AB5B58D /* [CP] Check Pods Manifest.lock */,
742 742
 				13B07F871A680F5B00A75B9A /* Sources */,
743 743
 				13B07F8C1A680F5B00A75B9A /* Frameworks */,
744 744
 				13B07F8E1A680F5B00A75B9A /* Resources */,
@@ -757,7 +757,7 @@
757 757
 			isa = PBXNativeTarget;
758 758
 			buildConfigurationList = 2D02E4BA1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget "simpleDemo-tvOS" */;
759 759
 			buildPhases = (
760
-				217E0836021B8C9E43808D99 /* [CP] Check Pods Manifest.lock */,
760
+				E79DD51971EBF6BE2FDAF290 /* [CP] Check Pods Manifest.lock */,
761 761
 				2D02E4771E0B4A5D006451C7 /* Sources */,
762 762
 				2D02E4781E0B4A5D006451C7 /* Frameworks */,
763 763
 				2D02E4791E0B4A5D006451C7 /* Resources */,
@@ -776,7 +776,7 @@
776 776
 			isa = PBXNativeTarget;
777 777
 			buildConfigurationList = 2D02E4BB1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget "simpleDemo-tvOSTests" */;
778 778
 			buildPhases = (
779
-				20C6BDC28229D769E1157E12 /* [CP] Check Pods Manifest.lock */,
779
+				9ABCD2800360B9BF14D66946 /* [CP] Check Pods Manifest.lock */,
780 780
 				2D02E48C1E0B4A5D006451C7 /* Sources */,
781 781
 				2D02E48D1E0B4A5D006451C7 /* Frameworks */,
782 782
 				2D02E48E1E0B4A5D006451C7 /* Resources */,
@@ -1217,29 +1217,21 @@
1217 1217
 			shellPath = /bin/sh;
1218 1218
 			shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
1219 1219
 		};
1220
-		20C6BDC28229D769E1157E12 /* [CP] Check Pods Manifest.lock */ = {
1220
+		2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = {
1221 1221
 			isa = PBXShellScriptBuildPhase;
1222 1222
 			buildActionMask = 2147483647;
1223 1223
 			files = (
1224 1224
 			);
1225
-			inputFileListPaths = (
1226
-			);
1227 1225
 			inputPaths = (
1228
-				"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
1229
-				"${PODS_ROOT}/Manifest.lock",
1230
-			);
1231
-			name = "[CP] Check Pods Manifest.lock";
1232
-			outputFileListPaths = (
1233 1226
 			);
1227
+			name = "Bundle React Native Code And Images";
1234 1228
 			outputPaths = (
1235
-				"$(DERIVED_FILE_DIR)/Pods-simpleDemo-tvOSTests-checkManifestLockResult.txt",
1236 1229
 			);
1237 1230
 			runOnlyForDeploymentPostprocessing = 0;
1238 1231
 			shellPath = /bin/sh;
1239
-			shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n    # print error to STDERR\n    echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n    exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
1240
-			showEnvVarsInLog = 0;
1232
+			shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
1241 1233
 		};
1242
-		217E0836021B8C9E43808D99 /* [CP] Check Pods Manifest.lock */ = {
1234
+		3D4AA6A23B06F1B41AB5B58D /* [CP] Check Pods Manifest.lock */ = {
1243 1235
 			isa = PBXShellScriptBuildPhase;
1244 1236
 			buildActionMask = 2147483647;
1245 1237
 			files = (
@@ -1254,28 +1246,36 @@
1254 1246
 			outputFileListPaths = (
1255 1247
 			);
1256 1248
 			outputPaths = (
1257
-				"$(DERIVED_FILE_DIR)/Pods-simpleDemo-tvOS-checkManifestLockResult.txt",
1249
+				"$(DERIVED_FILE_DIR)/Pods-simpleDemo-checkManifestLockResult.txt",
1258 1250
 			);
1259 1251
 			runOnlyForDeploymentPostprocessing = 0;
1260 1252
 			shellPath = /bin/sh;
1261 1253
 			shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n    # print error to STDERR\n    echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n    exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
1262 1254
 			showEnvVarsInLog = 0;
1263 1255
 		};
1264
-		2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = {
1256
+		4BEA691CDC159330D76026CC /* [CP] Check Pods Manifest.lock */ = {
1265 1257
 			isa = PBXShellScriptBuildPhase;
1266 1258
 			buildActionMask = 2147483647;
1267 1259
 			files = (
1268 1260
 			);
1261
+			inputFileListPaths = (
1262
+			);
1269 1263
 			inputPaths = (
1264
+				"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
1265
+				"${PODS_ROOT}/Manifest.lock",
1266
+			);
1267
+			name = "[CP] Check Pods Manifest.lock";
1268
+			outputFileListPaths = (
1270 1269
 			);
1271
-			name = "Bundle React Native Code And Images";
1272 1270
 			outputPaths = (
1271
+				"$(DERIVED_FILE_DIR)/Pods-simpleDemoTests-checkManifestLockResult.txt",
1273 1272
 			);
1274 1273
 			runOnlyForDeploymentPostprocessing = 0;
1275 1274
 			shellPath = /bin/sh;
1276
-			shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
1275
+			shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n    # print error to STDERR\n    echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n    exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
1276
+			showEnvVarsInLog = 0;
1277 1277
 		};
1278
-		BDA8D1EBEEE8A2517BA1F5A7 /* [CP] Check Pods Manifest.lock */ = {
1278
+		9ABCD2800360B9BF14D66946 /* [CP] Check Pods Manifest.lock */ = {
1279 1279
 			isa = PBXShellScriptBuildPhase;
1280 1280
 			buildActionMask = 2147483647;
1281 1281
 			files = (
@@ -1290,14 +1290,14 @@
1290 1290
 			outputFileListPaths = (
1291 1291
 			);
1292 1292
 			outputPaths = (
1293
-				"$(DERIVED_FILE_DIR)/Pods-simpleDemo-checkManifestLockResult.txt",
1293
+				"$(DERIVED_FILE_DIR)/Pods-simpleDemo-tvOSTests-checkManifestLockResult.txt",
1294 1294
 			);
1295 1295
 			runOnlyForDeploymentPostprocessing = 0;
1296 1296
 			shellPath = /bin/sh;
1297 1297
 			shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n    # print error to STDERR\n    echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n    exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
1298 1298
 			showEnvVarsInLog = 0;
1299 1299
 		};
1300
-		EAF58240469798C6B16617A5 /* [CP] Check Pods Manifest.lock */ = {
1300
+		E79DD51971EBF6BE2FDAF290 /* [CP] Check Pods Manifest.lock */ = {
1301 1301
 			isa = PBXShellScriptBuildPhase;
1302 1302
 			buildActionMask = 2147483647;
1303 1303
 			files = (
@@ -1312,7 +1312,7 @@
1312 1312
 			outputFileListPaths = (
1313 1313
 			);
1314 1314
 			outputPaths = (
1315
-				"$(DERIVED_FILE_DIR)/Pods-simpleDemoTests-checkManifestLockResult.txt",
1315
+				"$(DERIVED_FILE_DIR)/Pods-simpleDemo-tvOS-checkManifestLockResult.txt",
1316 1316
 			);
1317 1317
 			runOnlyForDeploymentPostprocessing = 0;
1318 1318
 			shellPath = /bin/sh;
@@ -1386,7 +1386,7 @@
1386 1386
 /* Begin XCBuildConfiguration section */
1387 1387
 		00E356F61AD99517003FC87E /* Debug */ = {
1388 1388
 			isa = XCBuildConfiguration;
1389
-			baseConfigurationReference = 2518E82A5EEFEBCCB546686E /* Pods-simpleDemoTests.debug.xcconfig */;
1389
+			baseConfigurationReference = 61D6128EB7E59612F733FF02 /* Pods-simpleDemoTests.debug.xcconfig */;
1390 1390
 			buildSettings = {
1391 1391
 				BUNDLE_LOADER = "$(TEST_HOST)";
1392 1392
 				DEVELOPMENT_TEAM = 56968F5P8G;
@@ -1411,7 +1411,7 @@
1411 1411
 		};
1412 1412
 		00E356F71AD99517003FC87E /* Release */ = {
1413 1413
 			isa = XCBuildConfiguration;
1414
-			baseConfigurationReference = B3CA7DAF4D391036EC75502F /* Pods-simpleDemoTests.release.xcconfig */;
1414
+			baseConfigurationReference = 2C28A102506C6EC8AEEADEBB /* Pods-simpleDemoTests.release.xcconfig */;
1415 1415
 			buildSettings = {
1416 1416
 				BUNDLE_LOADER = "$(TEST_HOST)";
1417 1417
 				COPY_PHASE_STRIP = NO;
@@ -1433,7 +1433,7 @@
1433 1433
 		};
1434 1434
 		13B07F941A680F5B00A75B9A /* Debug */ = {
1435 1435
 			isa = XCBuildConfiguration;
1436
-			baseConfigurationReference = 45C3C66C498C5DD68AEA83DB /* Pods-simpleDemo.debug.xcconfig */;
1436
+			baseConfigurationReference = B8C83FE8120F5A8CA66DC95D /* Pods-simpleDemo.debug.xcconfig */;
1437 1437
 			buildSettings = {
1438 1438
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
1439 1439
 				CURRENT_PROJECT_VERSION = 1;
@@ -1466,7 +1466,7 @@
1466 1466
 		};
1467 1467
 		13B07F951A680F5B00A75B9A /* Release */ = {
1468 1468
 			isa = XCBuildConfiguration;
1469
-			baseConfigurationReference = 5B50FE91740B45AD2B2FFA43 /* Pods-simpleDemo.release.xcconfig */;
1469
+			baseConfigurationReference = D411D46516249CACE14D41DC /* Pods-simpleDemo.release.xcconfig */;
1470 1470
 			buildSettings = {
1471 1471
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
1472 1472
 				CURRENT_PROJECT_VERSION = 1;
@@ -1498,7 +1498,7 @@
1498 1498
 		};
1499 1499
 		2D02E4971E0B4A5E006451C7 /* Debug */ = {
1500 1500
 			isa = XCBuildConfiguration;
1501
-			baseConfigurationReference = 670CBBAFD05743865934B941 /* Pods-simpleDemo-tvOS.debug.xcconfig */;
1501
+			baseConfigurationReference = 4562E79007DAB0C0D6F958BC /* Pods-simpleDemo-tvOS.debug.xcconfig */;
1502 1502
 			buildSettings = {
1503 1503
 				ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image";
1504 1504
 				ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
@@ -1527,7 +1527,7 @@
1527 1527
 		};
1528 1528
 		2D02E4981E0B4A5E006451C7 /* Release */ = {
1529 1529
 			isa = XCBuildConfiguration;
1530
-			baseConfigurationReference = 49AF4131548CCDDCC8317F3A /* Pods-simpleDemo-tvOS.release.xcconfig */;
1530
+			baseConfigurationReference = 3FE905B2466BFABBAA8F09A8 /* Pods-simpleDemo-tvOS.release.xcconfig */;
1531 1531
 			buildSettings = {
1532 1532
 				ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image";
1533 1533
 				ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
@@ -1556,7 +1556,7 @@
1556 1556
 		};
1557 1557
 		2D02E4991E0B4A5E006451C7 /* Debug */ = {
1558 1558
 			isa = XCBuildConfiguration;
1559
-			baseConfigurationReference = 425DC21FE0AD7CF5497EBBAD /* Pods-simpleDemo-tvOSTests.debug.xcconfig */;
1559
+			baseConfigurationReference = DCFC59650767B9DD307D635F /* Pods-simpleDemo-tvOSTests.debug.xcconfig */;
1560 1560
 			buildSettings = {
1561 1561
 				BUNDLE_LOADER = "$(TEST_HOST)";
1562 1562
 				CLANG_ANALYZER_NONNULL = YES;
@@ -1584,7 +1584,7 @@
1584 1584
 		};
1585 1585
 		2D02E49A1E0B4A5E006451C7 /* Release */ = {
1586 1586
 			isa = XCBuildConfiguration;
1587
-			baseConfigurationReference = 55F01DA43729E829E7920BE2 /* Pods-simpleDemo-tvOSTests.release.xcconfig */;
1587
+			baseConfigurationReference = 03E6606B86246B0AE5C5BFC5 /* Pods-simpleDemo-tvOSTests.release.xcconfig */;
1588 1588
 			buildSettings = {
1589 1589
 				BUNDLE_LOADER = "$(TEST_HOST)";
1590 1590
 				CLANG_ANALYZER_NONNULL = YES;

+ 36
- 317
src/RtcEngine.native.ts View File

@@ -1,14 +1,10 @@
1 1
 import {
2 2
     NativeModules,
3
-    NativeEventEmitter,
4
-    EmitterSubscription
3
+    NativeEventEmitter
5 4
 } from 'react-native';
6 5
 
7 6
 import {
8
-    Option, VideoOption,
9
-    EventScheduler,
10
-    PublisherConfig,
11
-    LiveTranscoding, Callback,
7
+    Option, Callback,
12 8
     String, Number
13 9
 } from "./types.d";
14 10
 
@@ -19,18 +15,15 @@ const AgoraEventEmitter = new NativeEventEmitter(Agora);
19 15
 /**
20 16
  * @class RtcEngine
21 17
  */
22
-export default class RtcEngine {
23
-
24
-    private static listeners: Array<EmitterSubscription>;
18
+const RtcEngine = { ...Agora,
19
+    eventTypes: new Set(),
25 20
     /**
26
-     * init AgoraRtcEngine
21
+     * init agora rtc engine and begin subscribe event immediately
27 22
      * @param options: Option
28 23
      */
29
-    static init(options: Option): void {
30
-        this.removeEmitter();
24
+    init(options: Option): void {
31 25
         Agora.init(options);
32
-        this.listeners = [];
33
-    }
26
+    },
34 27
 
35 28
     /**
36 29
      * join channel
@@ -40,328 +33,54 @@ export default class RtcEngine {
40 33
      * @param info Object extra info
41 34
      * @return Promise
42 35
      */
43
-    static joinChannel(channelName: String, uid?: Number, token?: String, info?: Object): void {
36
+    joinChannel(channelName: String, uid?: Number, token?: String, info?: Object): void {
44 37
         return Agora.joinChannel({channelName, uid, token, info});
45
-    }
38
+    },
46 39
 
47 40
     /**
48
-     * RtcEngine events register
49
-     * @param eventScheduler EventScheduler
41
+     * on - add event listener for react native event
42
+     * @param eventType String
43
+     * @param eventHandler Function
50 44
      */
51
-    static eventEmitter(eventScheduler: EventScheduler) {
52
-        this.removeEmitter();
53
-        // const events = EventSchedulerKeys;
54
-        const events = [
55
-            "onWarning",
56
-            "onError",
57
-            "onJoinChannelSuccess",
58
-            "onRejoinChannelSuccess",
59
-            "onLeaveChannel",
60
-            "onClientRoleChanged",
61
-            "onUserJoined",
62
-            "onUserOffline",
63
-            "onConnectionStateChanged",
64
-            "onConnectionInterrupted",
65
-            "onConnectionLost",
66
-            "onConnectionBanned",
67
-            "onApiCallExecuted",
68
-            "onTokenPrivilegeWillExpire",
69
-            "onRequestToken",
70
-            "onMicrophoneEnabled",
71
-            "onAudioVolumeIndication",
72
-            "onActiveSpeaker",
73
-            "onFirstLocalAudioFrame",
74
-            "onFirstRemoteAudioFrame",
75
-            "onVideoStopped",
76
-            "onFirstLocalVideoFrame",
77
-            "onFirstRemoteVideoDecoded",
78
-            "onFirstRemoteVideoFrame",
79
-            "onUserMuteAudio",
80
-            "onUserMuteVideo",
81
-            "onUserEnableVideo",
82
-            "onUserEnableLocalVideo",
83
-            "onVideoSizeChanged",
84
-            "onRemoteVideoStateChanged",
85
-            "onLocalPublishFallbackToAudioOnly",
86
-            "onRemoteSubscribeFallbackToAudioOnly",
87
-            "onAudioRouteChanged",
88
-            "onCameraReady",
89
-            "onCameraFocusAreaChanged",
90
-            "onCameraExposureAreaChanged",
91
-            "onAudioQuality",
92
-            "onRtcStats",
93
-            "onLastmileQuality",
94
-            "onNetworkQuality",
95
-            "onLocalVideoStats",
96
-            "onRemoteVideoStats",
97
-            "onRemoteAudioStats",
98
-            "onLocalVideoStat",
99
-            "onRemoteVideoStat",
100
-            "onRemoteAudioTransportStats",
101
-            "onRemoteVideoTransportStats",
102
-            "onAudioMixingFinished",
103
-            "onAudioEffectFinished",
104
-            "onStreamPublished",
105
-            "onStreamUnpublished",
106
-            "onTranscodingUpdated",
107
-            "onStreamInjectedStatus",
108
-            "onStreamMessage",
109
-            "onStreamMessageError",
110
-            "onMediaEngineLoadSuccess",
111
-            "onMediaEngineStartCallSuccess",
112
-        ];
113
-        for (let event of events) {
114
-            const functor = (eventScheduler as any)[event];
115
-            if (functor) {
116
-                this.listeners.push(
117
-                    AgoraEventEmitter.addListener(event, msg => {
118
-                        functor(msg);
119
-                    })
120
-                );
121
-            }
122
-        }
123
-    }
45
+    on(eventType: string, listener: (...args: any[]) => any) {
46
+        this.eventTypes.add(eventType);
47
+        AgoraEventEmitter.addListener(eventType, listener);
48
+    },
124 49
 
125 50
     /**
126
-     * remove emitter
51
+     * off - remove event listener for react native event
52
+     * @param eventType 
53
+     * @param listener 
127 54
      */
128
-    static removeEmitter() {
129
-        if (this.listeners && this.listeners.length > 0) {
130
-            for (let listener of this.listeners) {
131
-                listener.remove();
132
-                this.listeners = [];
133
-            }
134
-        }
135
-    }
55
+    off(eventType: string) {
56
+        AgoraEventEmitter.removeAllListeners(eventType);
57
+        this.eventTypes.delete(eventType);
58
+    },
136 59
 
137 60
     /**
138
-     * enableLastmileTest
139
-     * @return Promise
61
+     * removeAllListeners
140 62
      */
141
-    static enableLastmileTest() {
142
-        return Agora.enableLastmileTest();
143
-    }
144
-
145
-    /**
146
-     * disableLastmileTest
147
-     * @return Promise
148
-     */
149
-    static disableLastmileTest() {
150
-        return Agora.disableLastmileTest();
151
-    }
152
-
153
-    /**
154
-     * leaveChannel
155
-     * @return Promise
156
-     */  
157
-    static leaveChannel() {
158
-        return Agora.leaveChannel();
159
-    }
63
+    removeAllListeners () {
64
+        for (let eventType of this.eventTypes) {
65
+            this.off(eventType);
66
+        }
67
+        this.eventTypes.clear();
68
+    },
160 69
 
161 70
     /**
162 71
      * destroy AgoraRtcEngine
163
-     */  
164
-    static destroy() {
165
-        Agora.destroy();
166
-    }
167
-    
168
-    /**
169
-     * setupLocalVideo
170
-     * @param options: VideoOption
171
-     */  
172
-    static setupLocalVideo(options: VideoOption) {
173
-        Agora.setupLocalVideo(options);
174
-    }
175
-
176
-    /**
177
-     * setupRemoteVideo
178
-     * @param options: VideoOption
179
-     */  
180
-    static setupRemoteVideo(options: VideoOption) {
181
-        Agora.setupRemoteVideo(options);
182
-    }
183
-
184
-    /**
185
-     * start AgoraRtcEngine preview
186 72
      */
187
-    static startPreview() {
188
-        Agora.startPreview();
189
-    }
190
-
191
-    /**
192
-     * stop AgoraRtcEngine preview
193
-     */
194
-    static stopPreview() {
195
-        Agora.stopPreview();
196
-    }
197
-
198
-    /**
199
-     * start live trancoding
200
-     * @param options LiveTranscoding
201
-     */
202
-    static setLiveTranscoding(options: LiveTranscoding) {
203
-        Agora.setLiveTranscoding(options);
204
-    }
205
-
206
-    /**
207
-     * setLocalRenderMode
208
-     * @param mode Number
209
-     */
210
-    static setLocalRenderMode(mode: number) {
211
-        Agora.setLocalRenderMode(mode);
212
-    }
213
-
214
-    /**
215
-     * setRemoteRenderMode
216
-     * @param uid Number
217
-     * @param mode Number
218
-     */
219
-    static setRemoteRenderMode(uid: number, mode: number) {
220
-        Agora.setRemoteRenderMode(uid, mode);
221
-    }
222
-
223
-    /**
224
-     * enableAudioVolumeIndication
225
-     * @param interval Number
226
-     * @param smooth Number
227
-     */
228
-    static enableAudioVolumeIndication(interval: number, smooth: number) {
229
-        Agora.enableAudioVolumeIndication(interval, smooth);
230
-    }
231
-
232
-    /**
233
-     * switch camera
234
-     * @return Promise
235
-     */
236
-    static switchCamera() {
237
-        return Agora.switchCamera();
238
-    }
239
-
240
-    static enableVideo() {
241
-        Agora.enableVideo();
242
-    }
243
-
244
-    static disableVideo() {
245
-        Agora.disableVideo();
246
-    }
247
-
248
-    /**
249
-     * setEnableSpeakerphone
250
-     * @param status Boolena
251
-     */
252
-    static setEnableSpeakerphone(status: boolean) {
253
-        Agora.setEnableSpeakerphone(status);
254
-    }
255
-
256
-    /**
257
-     * muteLocalAudioStream
258
-     * @param status Boolena
259
-     */
260
-    static muteLocalAudioStream(status: boolean) {
261
-        Agora.muteLocalAudioStream(status);
262
-    }
263
-
264
-    /**
265
-     * muteRemoteAudioStream
266
-     * @param uid Number
267
-     * @param status Boolean
268
-     */
269
-    static muteRemoteAudioStream(uid: number, status: boolean) {
270
-        Agora.muteRemoteAudioStream(uid, status);
271
-    }
272
-
273
-    /**
274
-     * muteAllRemoteAudioStreams
275
-     * @param status Boolean
276
-     */
277
-    static muteAllRemoteAudioStreams(status: boolean) {
278
-        Agora.muteAllRemoteAudioStreams(status);
279
-    }
280
-
281
-    /**
282
-     * setCameraTorchOn
283
-     * @param status Boolean
284
-     * @return Promise
285
-     */
286
-    static setCameraTorchOn(status: boolean) {
287
-        return Agora.setCameraTorchOn(status);
288
-    }
289
-
290
-    /**
291
-     * setCameraAutoFocusFaceModeEnabled
292
-     * @param status Boolean
293
-     * @return Promise
294
-     */
295
-    static setCameraAutoFocusFaceModeEnabled(status: boolean) {
296
-        return Agora.setCameraAutoFocusFaceModeEnabled(status);
297
-    }
298
-
299
-    /**
300
-     * setDefaultAudioRouteToSpeakerphone
301
-     * @param status Boolean
302
-     * @return Promise
303
-     */
304
-    static setDefaultAudioRouteToSpeakerphone(status: boolean) {
305
-        Agora.setDefaultAudioRouteToSpeakerphone(status);
306
-    }
307
-
308
-    /**
309
-     * muteLocalVideoStream
310
-     * @param status Boolean
311
-     */
312
-    static muteLocalVideoStream(status: boolean) {
313
-        Agora.muteLocalVideoStream(status);
314
-    }
315
-
316
-    /**
317
-     * enableLocalVideo
318
-     * @param status Boolean
319
-     */
320
-    static enableLocalVideo(status: boolean) {
321
-        Agora.enableLocalVideo(status);
322
-    }
323
-
324
-    /**
325
-     * muteAllRemoteVideoStreams
326
-     * @param status Boolean
327
-     */
328
-    static muteAllRemoteVideoStreams(status: boolean) {
329
-        Agora.muteAllRemoteVideoStreams(status);
330
-    }
331
-
332
-    /**
333
-     * muteRemoteVideoStream
334
-     * @param status Boolean
335
-     */
336
-    static muteRemoteVideoStream(uid: number, status: boolean) {
337
-        Agora.muteRemoteVideoStream(uid, status);
338
-    }
339
-
340
-    /**
341
-     * createDataStream
342
-     * @param reliable Boolean
343
-     * @param ordered Boolean
344
-     * @return Promise
345
-     */
346
-    static createDataStream(reliable: boolean, ordered: boolean) {
347
-        return Agora.createDataStream({reliable, ordered});
348
-    }
349
-
350
-    /**
351
-     * sendStreamMessage
352
-     * @param reliable Boolean
353
-     * @param ordered Boolean
354
-     * @return Promise
355
-     */
356
-    static sendStreamMessage(streamId: number, data: any) {
357
-        return Agora.sendStreamMessage(streamId, data);
358
-    }
73
+    destroy() {
74
+        Agora.destroy();
75
+    },
359 76
 
360 77
     /**
361 78
      * getSdkVersion
362 79
      * @param callback Function
363 80
      */
364
-    static getSdkVersion(callback: Callback<void>) {
81
+    getSdkVersion(callback: Callback<void>) {
365 82
         Agora.getSdkVersion().then(callback);
366 83
     }
367 84
 };
85
+
86
+export default RtcEngine;

+ 5
- 0
src/types.d.ts View File

@@ -91,6 +91,11 @@ export interface VideoOption {
91 91
   reactTag: number
92 92
 }
93 93
 
94
+export interface AudioRecordingOption {
95
+  filePath: String,
96
+  quality: Number
97
+}
98
+
94 99
 export interface EventScheduler {
95 100
   onWarning: Function,
96 101