MainActivity.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package com.example.nexilissamplecodeionic;
  2. import java.util.ArrayList;
  3. import android.os.Bundle;
  4. import android.widget.Toast;
  5. import com.getcapacitor.BridgeActivity;
  6. import io.nexilis.ui.API;
  7. import io.nexilis.ui.Callback;
  8. import io.nexilis.ui.utils.callback.SimCardDetectionCallback;
  9. import io.nexilis.ui.utils.xthunder.FloatingButton;
  10. import io.nexilis.ss.SecurityShield;
  11. public class MainActivity extends BridgeActivity {
  12. @Override
  13. protected void onCreate(Bundle savedInstanceState) {
  14. registerPlugin(NativePlugin.class);
  15. super.onCreate(savedInstanceState);
  16. /**
  17. *
  18. * Nexilis provides an API security shield service, which functions to detect threats such as malware, ADB, screencapture, and Sim Swapping.
  19. */
  20. //SECURITY
  21. //SMS
  22. //EMAIL
  23. //SMARTBOT
  24. /*************************************
  25. Connect to our server with your nexilis.io Account, and implement the required Callback.
  26. Please Subscribe or contact us to get your nexilis.io Account.
  27. Do not share your nexilis.io Account or ever give it out to someone outside your organization.
  28. ************************************/
  29. /**
  30. * API.connect (String ApplicationName, String NexilisAccount, Activity RegisteredActivity, int NexilisButtonMode, boolean UserMayModifyUID, Callback ConnectCallback)
  31. *
  32. * ApplicationName : Your Nexilis.io application name.
  33. * NexilisAccount : Your Nexilis.io Account.
  34. * RegisteredActivity : Android's Activity class that is used to register the Nexilis Button
  35. * NexilisButtonMode : The flag that determines when the Nexilis Button should appear.
  36. * 0 = Disabled Nexilis Button
  37. * 1 = Within registered Activity, (Nexilis Button only appears when users are in the registered activity)
  38. * 2 = Within App (Nexilis Button always appears as long as user is in the App),
  39. * 3 = Always On (Nexilis Button always appears even if the application process is closed)
  40. * UserMayModifyUID : Sets whether users are allowed to change the Nexilis UserID.
  41. * true = enabled,
  42. * false = disabled
  43. * ConnectCallback : The callback interface to be invoked when calling the method connect.
  44. * You need to implement onSuccess(String NexilisUserID) & onFailed(String reasonCode) to handle the RESULT.
  45. *
  46. */
  47. int nexilisButtonMode = 0;
  48. API.connect("***REPLACE***WITH***YOUR***APPLICATION***NAME***", "***REPLACE***WITH***YOUR***NEXILIS***ACCOUNT***", this, nexilisButtonMode, 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. SecurityShield.getInstance().check("***REPLACE***WITH***YOUR***APPLICATION***NAME***", "***REPLACE***WITH***YOUR***NEXILIS***ACCOUNT***",MainActivity.this);
  57. runOnUiThread(new Runnable() {
  58. @Override
  59. public void run() {
  60. //FLOATING
  61. Toast.makeText(getBaseContext(), "Your User ID: " + NexilisUserID + " : " + getString(io.nexilis.ui.R.string.pb_loading), Toast.LENGTH_LONG).show();
  62. }
  63. });
  64. }
  65. @Override
  66. public void onFailed(final String reasonCode) {
  67. /**
  68. * reasonCode : Returns a code based on the status of the function connect called.
  69. * 2:Your trial subscription has expired. Please subscribe to continue using Nexilis.
  70. * 3:Your monthly subscription is not paid in full. Please pay your monthly subscription bill to continue using Nexilis service.
  71. * 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
  72. * 23:Unsupported Android version
  73. * 93:Missing the required overlay permission
  74. * 94:Unregistered User
  75. * 95:Invalid Nexilis Button Mode (1,2,3)
  76. * 96:Activity is null
  77. * 97:Account is empty
  78. * 98:Your account didn't match
  79. * 99:Something went wrong
  80. */
  81. runOnUiThread(new Runnable() {
  82. @Override
  83. public void run() {
  84. Toast.makeText(getBaseContext(), reasonCode, Toast.LENGTH_LONG).show();
  85. }
  86. });
  87. }
  88. });
  89. }
  90. }