You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

210 lines
7.5 KiB
Markdown

[< Back](android.md)
## Integrating and Configuring PenNavUI
## 5. Run the Plug & Play (P&P) Module
To implement the PenNavUIDelegate interface in your Java project and begin calling the P&P
functions, follow this steps:
1. From your project implement the PenNavUIDelegate to start calling the P&P functions
```java
public class MyClass implements PenNavUIDelegate {}
```
2. In the class where you implement the PenNavUIDelegate interface, you need to call three
functions :
a. **onPenNavSuccess** : The triggering of this callback signifies the successful initialization of
the P&P module.
```java
@Override
public void onPenNavSuccess(String warning) {}
```
b. **onPenNavInitializationError** : callback is triggered upon the failure of the P&P module
initialization process.
```java
@Override
public void onPenNavInitializationError(String description, InitializationErrorType errorType) {}
```
c. **onPenNavUIDismiss** : callback is triggered upon the successful closure of the P&P module, which
is initiated by the clicking of the back button.
```java
@Override
public void onPenNavUIDismiss() {}
```
3. Setup the P&P configuration using **PlugAndPlayConfiguration.Builder**
```java
private PlugAndPlayConfiguration.Builder builder=new PlugAndPlayConfiguration.Builder();
```
4. From the class that used to start the P&P module,setup the P&P configurations
There are two types of configurations (mandatory and optional).
a. Mandatory configuration : if these configurations are not setup , the P&P module
initialization will fail
```java
PlugAndPlaySDK.configuration = builder
.setBaseUrl(dataServerUrl, positionServerUrl)
.setServiceName(dataServiceName,positionServiceName)
.setClientData(clientID, clientKey)
.setUserName(name)
```
| Config | Link |
|----------------|----------------------------------------------------|
| setBaseUrl | [description](./readmeresources/setBaseUrl.md) |
| setServiceName | [description](./readmeresources/setServiceName.md) |
| setClientData | [description](./readmeresources/setClientData.md) |
| setUserName | [description](./readmeresources/setUserName.md) |
b. And other optional configurations, you have the option to add them or ignore them and it will not affect the app performance
```java
builder.setSimulationModeEnabled(isSimulation)
.setLanguageID(languageCode)
.setCustomizeColor(hexCode)
.setDeepLinkSchema(deepLinkSchema)
.setDeepLinkData(deepLinkReceivedData)
```
| Config | Link |
|--------------------------|-------------------------------------------------------|
| setSimulationModeEnabled | [description](./readmeresources/setSimulationMode.md) |
| setLanguageID | [description](./readmeresources/setLanguage.md) |
| setCustomizeColor | [description](./readmeresources/setCustomizeColor.md) |
| setDeepLinkData | [description](./readmeresources/setDeepLinkData.md) |
| setDeepLinkSchema | [description](./readmeresources/setDeepLinkSchema.md) |
**After Setting configuration**
You need to build the configuration
```java
builder.build()
```
**Start initializing our SDK**
Call the initialize(Context, PenNavUIDelegate) method providing an object that implements PenNavUIDelegate.
```java
PlugAndPlaySDK.start(Context,PenNavUIDelegate);
```
## 6. Possibly another implementation is needed
### 1. Implementing the Off Location Campus Delegate
In this callBack if the user is offCampus you can get the location as (Latitude and Longitude)
Take the following steps to get notified if the user location is off-campus:
1. From your project Implement the `PILocationDelegate` interface and
its `onLocationOffCampus(ArrayList<Double> location)` method that gets called back when the user
location is off-campus with an array of floating-point numbers as a parameter that represents
off-campus latitude and longitude.
```java
public class MyClass extends AppCompatActivity implements PILocationDelegate
```
2. In the class where you implement the PILocationDelegate interface, you can call one method
```java
public class MyClass extends AppCompatActivity implements PILocationDelegate {
@Override
public void onLocationOffCampus(ArrayList<Double> location) {}
}
```
You will receive an arrayList of double points of Latitude and longitude
Example of how you can use the data :
```java
if (location.size() > 0)
Toast.makeText(mContext , "Location Info Latitude : " + location.get(0) + " longitude : " + location.get(1) , Toast.LENGTH_SHORT).show();
```
And the data will shown as :
Location Info Latitude : 31.656546 longitude : 35.46146
3. During the map initializing step, set the `PILocationDelegate` in the `setPiLocationDelegate`
method to an object that implements the `PILocationDelegate` interface and
its `ArrayList<Double> location)` method.
```java
PlugAndPlaySDK.setPiLocationDelegate(PILocationDelegate);
```
### 2. Navigating to Places on the Map
**Using Reference IDs**
You can use this method From PlugAndPlaySDK class and use it if you want to show the Poi on the map
and navigate to it
Call the `navigateTo(Context mContext, String referenceID, Completion completion)` method to
navigate to a place given its reference ID.
```java
PlugAndPlaySDK.navigateTo(Context,String,Completion)
```
**Using shared Links**
1. Provide a shared link for plug-and-play to share user or Poi location on the map using
the `setDeepLinkSchema(String)` method
```java
PlugAndPlayConfiguration.Builder().setDeepLinkSchema(String)
```
2. Provide data from a deep link to display places on the map using the `setDeepLinkData(String)`
method
```java
PlugAndPlayConfiguration.Builder().setDeepLinkData(String)
```
### 3. Reporting an Issue
The PlugAndPlaySDK provides a flexible way to capture and report issues within your application. By using a delegate, you can seamlessly integrate third-party tools
or your end point to streamline the process of issue reporting and debugging.
#### Setting Up the Delegate
To enable issue reporting with PlugAndPlaySDK, you need to set up a delegate by calling the `setPiEventsDelegate` method. The delegate is responsible for handling issue reports. Here's the basic setup:
```java
PlugAndPlaySDK.setPiEventsDelegate(new PIEventsDelegate() {
@Override
public void onReportIssue(PIReportIssue issue) {
// Implement issue reporting logic here
}
});
```
In this code snippet, we define an anonymous inner class that implements the `PIEventsDelegate` interface. The `onReportIssue` method is where you will place the logic for reporting issues to your chosen tool.
#### Controlling Report Issue Buttons in PlugAndPlaySDK
You can easily enable or disable report issue buttons in PlugAndPlaySDK based on your application's needs.
#### Usage
- **Enable Report Issue Buttons**:
```java
PlugAndPlaySDK.setReportingIssuesEnabled(true);
```
Use this when you want users to report issues.
- **Disable Report Issue Buttons**:
```java
PlugAndPlaySDK.setReportingIssuesEnabled(false);
```
Use this to prevent users from reporting issues.
[< Back](android.md)