MainActivity.java 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package com.example.nexilissamplecodeflutter;
  2. import android.os.Bundle;
  3. import android.widget.Toast;
  4. import androidx.annotation.NonNull;
  5. import androidx.annotation.Nullable;
  6. import java.util.Map;
  7. import io.flutter.embedding.android.FlutterActivity;
  8. import io.flutter.embedding.engine.FlutterEngine;
  9. import io.flutter.plugin.common.MethodChannel;
  10. import io.nexilis.service.API;
  11. import io.nexilis.service.Callback;
  12. import io.nexilis.service.utils.callback.SimCardDetectionCallback;
  13. import io.nexilis.service.utils.xthunder.FloatingButton;
  14. public class MainActivity extends FlutterActivity {
  15. private static final String CHANNEL = "nativeChannel";
  16. @Override
  17. protected void onCreate(@Nullable Bundle savedInstanceState) {
  18. super.onCreate(savedInstanceState);
  19. /**
  20. *
  21. * Nexilis provides an API security shield service, which functions to detect threats such as malware, ADB, screencapture, and Sim Swapping.
  22. */
  23. //SECURITY
  24. //SMS
  25. //EMAIL
  26. /*************************************
  27. Connect to our server with your newuniverse.io Account, and implement the required Callback.
  28. Please Subscribe or contact us to get your newuniverse.io Account.
  29. Do not share your newuniverse.io Account or ever give it out to someone outside your organization.
  30. ************************************/
  31. /**
  32. * API.connect (String NexilisAccount, Activity RegisteredActivity, int NexilisButtonMode, boolean UserMayModifyUID, Callback ConnectCallback)
  33. *
  34. * NexilisAccount : Your Nexilis.io Account.
  35. * RegisteredActivity : Android's Activity class that is used to register the Nexilis Button
  36. * NexilisButtonMode : The flag that determines when the Nexilis Button should appear.
  37. * 0 = Disabled Nexilis Button
  38. * 1 = Within registered Activity, (Nexilis Button only appears when users are in the registered activity)
  39. * 2 = Within App (Nexilis Button always appears as long as user is in the App),
  40. * 3 = Always On (Nexilis Button always appears even if the application process is closed)
  41. * UserMayModifyUID : Sets whether users are allowed to change the Nexilis UserID.
  42. * true = enabled,
  43. * false = disabled
  44. * ConnectCallback : The callback interface to be invoked when calling the method connect.
  45. * You need to implement onSuccess(String NexilisUserID) & onFailed(String reasonCode) to handle the RESULT.
  46. *
  47. */
  48. API.connect("***REPLACE***WITH***YOUR***NEXILIS***ACCOUNT***", this, 0, new Callback() {
  49. @Override
  50. public void onSuccess(final String NexilisUserID) {
  51. /**************************************
  52. The NexilisUserID parameter is generated automatically and can be mapped to a User ID on the application level.
  53. For example, the Nexilis User ID (e.g. User001) can be mapped into the corresponding Application User ID (e.g. John Doe),
  54. so you don't have to share your Application User ID with Nexilis while still being able to monitor your user activities.
  55. **************************************/
  56. runOnUiThread(new Runnable() {
  57. @Override
  58. public void run() {
  59. //FLOATING
  60. Toast.makeText(getBaseContext(), "Your User ID: " + NexilisUserID + " : " + getString(io.nexilis.service.R.string.pb_loading), Toast.LENGTH_LONG).show();
  61. }
  62. });
  63. }
  64. @Override
  65. public void onFailed(final String reasonCode) {
  66. /**
  67. * reasonCode : Returns a code based on the status of the function connect called.
  68. * 2:Your trial subscription has expired. Please subscribe to continue using Nexilis.
  69. * 3:Your monthly subscription is not paid in full. Please pay your monthly subscription bill to continue using Nexilis service.
  70. * 4:Your Customer Engagement Credit has run out and your Prepaid Credit Balance is empty. Please top-up your Prepaid Credit Balance to continue using Nexilis
  71. * 23:Unsupported Android version
  72. * 93:Missing the required overlay permission
  73. * 94:Unregistered User
  74. * 95:Invalid Nexilis Button Mode (1,2,3)
  75. * 96:Activity is null
  76. * 97:Account is empty
  77. * 98:Your account didn't match
  78. * 99:Something went wrong
  79. */
  80. runOnUiThread(new Runnable() {
  81. @Override
  82. public void run() {
  83. Toast.makeText(getBaseContext(), reasonCode, Toast.LENGTH_LONG).show();
  84. }
  85. });
  86. }
  87. });
  88. }
  89. @Override
  90. public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
  91. super.configureFlutterEngine(flutterEngine);
  92. new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL).setMethodCallHandler((call, result) -> {
  93. if (call.method.equals("openContactCenter")) {
  94. String response = API.openContactCenter();
  95. result.success(response);
  96. } else if (call.method.equals("openInstantMessaging")) {
  97. String response = API.openChat();
  98. result.success(response);
  99. } else if (call.method.equals("openCall")) {
  100. String response = API.openCall();
  101. result.success(response);
  102. } else if (call.method.equals("openStreaming")) {
  103. String response = API.openLiveStreaming();
  104. result.success(response);
  105. } else if (call.method.equals("openSettings")) {
  106. API.openSettings();
  107. } else if (call.method.equals("openWhiteboard")) {
  108. String response = API.openWhiteboard();
  109. result.success(response);
  110. } else if (call.method.equals("openChatGPT")) {
  111. String response = API.openSmartChatbot();
  112. result.success(response);
  113. } else if (call.method.equals("openContactCenterChat")) {
  114. Map<String, Integer> map = (Map<String, Integer>) call.arguments;
  115. int category = map.get("category");
  116. String response = API.openContactCenter(0, category);
  117. result.success(response);
  118. } else if (call.method.equals("openContactCenterAudioCall")) {
  119. Map<String, Integer> map = (Map<String, Integer>) call.arguments;
  120. int category = map.get("category");
  121. String response = API.openContactCenter(1, category);
  122. result.success(response);
  123. } else if (call.method.equals("openContactCenterVideoCall")) {
  124. Map<String, Integer> map = (Map<String, Integer>) call.arguments;
  125. int category = map.get("category");
  126. String response = API.openContactCenter(2, category);
  127. result.success(response);
  128. } else if (call.method.equals("signInAdmin")) {
  129. Map<String, String> map = (Map<String, String>) call.arguments;
  130. String pwd = map.get("pwd");
  131. String response = API.signInAdmin(pwd);
  132. result.success(response);
  133. } else if (call.method.equals("openSetOfficer")) {
  134. String response = API.openSetAsOfficerForm();
  135. result.success(response);
  136. }
  137. });
  138. }
  139. }