Skip to main content

Platform Integration Guide

This guide provides platform-specific integration examples for the Cirvia Parental SDK. Learn how to implement content monitoring for popular platforms and game engines that children commonly use.

Overview​

Different platforms have unique content creation patterns and APIs. This guide covers:

  • Gaming Platforms (Roblox, Minecraft, Unity games)
  • Social Media (Instagram-style apps, TikTok-style apps)
  • Messaging Apps (Discord bots, chat applications)
  • Educational Apps (Learning platforms, creative tools)

Gaming Platform Integration​

Roblox-Style Game Integration​

public class RobloxGameMonitor {

// Monitor in-game chat messages
public void onPlayerChatMessage(String playerId, String message) {
// Monitor all public chat
ParentalAI.sendTextIncident("roblox-chat", message);

// Display message in game
displayChatMessage(playerId, message);
}

// Monitor private messaging system
public void onPrivateMessage(String senderId, String recipientId, String message) {
ParentalAI.sendTextIncident("roblox-private", message);
deliverPrivateMessage(senderId, recipientId, message);
}

// Monitor custom game object names
public void onGameObjectCreated(String objectName, String creatorId) {
if (objectName != null && !objectName.trim().isEmpty()) {
ParentalAI.sendTextIncident("roblox-object", objectName);
}
createGameObject(objectName, creatorId);
}

// Monitor custom decals and images
public void onDecalUploaded(Bitmap decalImage, String uploaderId) {
try {
String base64Image = ImageEncoder.encodeImageToBase64(decalImage);
ParentalAI.sendImageIncident("roblox-decal", base64Image);
processDecalUpload(decalImage, uploaderId);
} catch (Exception e) {
Log.e("RobloxMonitor", "Failed to monitor decal", e);
}
}

// Monitor player usernames when they join servers
public void onPlayerJoinedServer(String username, String playerId) {
ParentalAI.sendTextIncident("roblox-username", username);
addPlayerToServer(username, playerId);
}

// Monitor game descriptions and titles
public void onGameInfoUpdated(String gameTitle, String gameDescription) {
ParentalAI.sendTextIncident("roblox-title", gameTitle);
if (gameDescription != null && !gameDescription.trim().isEmpty()) {
ParentalAI.sendTextIncident("roblox-description", gameDescription);
}
updateGameInfo(gameTitle, gameDescription);
}
}

Unity Game Integration​

public class UnityGameMonitor {

// Monitor multiplayer chat
public void onMultiplayerChat(String playerName, String message) {
ParentalAI.sendTextIncident("unity-multiplayer", message);
broadcastChatMessage(playerName, message);
}

// Monitor custom level/world names
public void onCustomLevelCreated(String levelName, String creatorId) {
ParentalAI.sendTextIncident("unity-level", levelName);
saveLevelToCloud(levelName, creatorId);
}

// Monitor screenshot sharing
public void onScreenshotShared(byte[] screenshotData) {
String base64Image = Base64.encodeToString(screenshotData, Base64.DEFAULT);
ParentalAI.sendImageIncident("unity-screenshot", base64Image);
uploadScreenshot(screenshotData);
}

// Monitor voice chat transcription (if using speech-to-text)
public void onVoiceChatTranscribed(String transcribedText, String speakerId) {
if (transcribedText != null && transcribedText.length() > 5) {
ParentalAI.sendTextIncident("unity-voice", transcribedText);
}
}
}

Minecraft-Style Game Integration​

public class MinecraftStyleMonitor {

// Monitor chat commands
public void onChatCommand(String command, String playerId) {
// Monitor both commands and regular chat
ParentalAI.sendTextIncident("minecraft-chat", command);
executeCommand(command, playerId);
}

// Monitor signs and books
public void onSignTextUpdated(String signText, int x, int y, int z) {
ParentalAI.sendTextIncident("minecraft-sign", signText);
updateSignAtLocation(signText, x, y, z);
}

public void onBookWritten(String bookContent, String authorId) {
ParentalAI.sendTextIncident("minecraft-book", bookContent);
saveBookToInventory(bookContent, authorId);
}

// Monitor custom skins
public void onSkinUploaded(Bitmap skinImage, String playerId) {
try {
String base64Image = ImageEncoder.encodeImageToBase64(skinImage);
ParentalAI.sendImageIncident("minecraft-skin", base64Image);
applySkinToPlayer(skinImage, playerId);
} catch (Exception e) {
Log.e("MinecraftMonitor", "Failed to monitor skin", e);
}
}

// Monitor server names and descriptions
public void onServerCreated(String serverName, String serverDescription) {
ParentalAI.sendTextIncident("minecraft-server", serverName);
if (serverDescription != null) {
ParentalAI.sendTextIncident("minecraft-server-desc", serverDescription);
}
createMultiplayerServer(serverName, serverDescription);
}
}

Social Media Integration​

Instagram-Style App Integration​

public class InstagramStyleMonitor {

// Monitor post captions and hashtags
public void onPostCreated(String caption, List<String> hashtags, Bitmap image) {
// Monitor text content
if (caption != null && !caption.trim().isEmpty()) {
ParentalAI.sendTextIncident("instagram-caption", caption);
}

// Monitor hashtags
for (String hashtag : hashtags) {
ParentalAI.sendTextIncident("instagram-hashtag", hashtag);
}

// Monitor image
try {
String base64Image = ImageEncoder.encodeImageToBase64(image);
ParentalAI.sendImageIncident("instagram-post", base64Image);
} catch (Exception e) {
Log.e("InstagramMonitor", "Failed to monitor post image", e);
}

publishPost(caption, hashtags, image);
}

// Monitor story content
public void onStoryPosted(String storyText, Bitmap storyImage) {
if (storyText != null) {
ParentalAI.sendTextIncident("instagram-story-text", storyText);
}

if (storyImage != null) {
try {
String base64Image = ImageEncoder.encodeImageToBase64(storyImage);
ParentalAI.sendImageIncident("instagram-story", base64Image);
} catch (Exception e) {
Log.e("InstagramMonitor", "Failed to monitor story image", e);
}
}

publishStory(storyText, storyImage);
}

// Monitor direct messages
public void onDirectMessageSent(String recipientId, String message, Bitmap image) {
if (message != null) {
ParentalAI.sendTextIncident("instagram-dm", message);
}

if (image != null) {
try {
String base64Image = ImageEncoder.encodeImageToBase64(image);
ParentalAI.sendImageIncident("instagram-dm-image", base64Image);
} catch (Exception e) {
Log.e("InstagramMonitor", "Failed to monitor DM image", e);
}
}

sendDirectMessage(recipientId, message, image);
}

// Monitor comments
public void onCommentPosted(String postId, String comment) {
ParentalAI.sendTextIncident("instagram-comment", comment);
postComment(postId, comment);
}

// Monitor profile updates
public void onProfileUpdated(String bio, String displayName, Bitmap profilePicture) {
if (bio != null) {
ParentalAI.sendTextIncident("instagram-bio", bio);
}

if (displayName != null) {
ParentalAI.sendTextIncident("instagram-name", displayName);
}

if (profilePicture != null) {
try {
String base64Image = ImageEncoder.encodeImageToBase64(profilePicture);
ParentalAI.sendImageIncident("instagram-profile-pic", base64Image);
} catch (Exception e) {
Log.e("InstagramMonitor", "Failed to monitor profile picture", e);
}
}

updateProfile(bio, displayName, profilePicture);
}
}

TikTok-Style App Integration​

public class TikTokStyleMonitor {

// Monitor video descriptions and hashtags
public void onVideoUploaded(String description, List<String> hashtags, String videoPath) {
// Monitor description
if (description != null && !description.trim().isEmpty()) {
ParentalAI.sendTextIncident("tiktok-description", description);
}

// Monitor hashtags
for (String hashtag : hashtags) {
ParentalAI.sendTextIncident("tiktok-hashtag", hashtag);
}

// Extract and monitor video thumbnail
Bitmap thumbnail = extractVideoThumbnail(videoPath);
if (thumbnail != null) {
try {
String base64Image = ImageEncoder.encodeImageToBase64(thumbnail);
ParentalAI.sendImageIncident("tiktok-thumbnail", base64Image);
} catch (Exception e) {
Log.e("TikTokMonitor", "Failed to monitor thumbnail", e);
}
}

uploadVideo(description, hashtags, videoPath);
}

// Monitor comments on videos
public void onCommentPosted(String videoId, String comment) {
ParentalAI.sendTextIncident("tiktok-comment", comment);
postVideoComment(videoId, comment);
}

// Monitor direct messages
public void onDirectMessage(String recipientId, String message) {
ParentalAI.sendTextIncident("tiktok-dm", message);
sendDirectMessage(recipientId, message);
}

// Monitor live stream chat
public void onLiveStreamChat(String streamId, String message, String senderId) {
ParentalAI.sendTextIncident("tiktok-live", message);
sendLiveMessage(streamId, message, senderId);
}

private Bitmap extractVideoThumbnail(String videoPath) {
try {
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(videoPath);
return retriever.getFrameAtTime(0, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
} catch (Exception e) {
Log.e("TikTokMonitor", "Failed to extract thumbnail", e);
return null;
}
}
}

Messaging Platform Integration​

Discord Bot Integration​

public class DiscordBotMonitor {

// Monitor text messages in channels
public void onMessageReceived(String channelId, String authorId, String content) {
if (content != null && !content.trim().isEmpty()) {
ParentalAI.sendTextIncident("discord-message", content);
}

// Process message normally
processChannelMessage(channelId, authorId, content);
}

// Monitor direct messages
public void onDirectMessageReceived(String senderId, String content) {
ParentalAI.sendTextIncident("discord-dm", content);
processDirectMessage(senderId, content);
}

// Monitor image attachments
public void onImageAttachment(String channelId, String imageUrl) {
// Download and monitor image
new Thread(() -> {
try {
Bitmap image = downloadImageFromUrl(imageUrl);
if (image != null) {
String base64Image = ImageEncoder.encodeImageToBase64(image);
ParentalAI.sendImageIncident("discord-image", base64Image);
}
} catch (Exception e) {
Log.e("DiscordMonitor", "Failed to monitor image attachment", e);
}
}).start();
}

// Monitor emoji reactions (custom emojis may contain inappropriate content)
public void onEmojiReaction(String messageId, String emojiName) {
if (emojiName != null && emojiName.length() > 2) {
ParentalAI.sendTextIncident("discord-emoji", emojiName);
}
}

// Monitor server/channel creation
public void onChannelCreated(String channelName, String topic) {
ParentalAI.sendTextIncident("discord-channel", channelName);
if (topic != null && !topic.trim().isEmpty()) {
ParentalAI.sendTextIncident("discord-topic", topic);
}
}

// Monitor nickname changes
public void onNicknameChanged(String userId, String newNickname) {
ParentalAI.sendTextIncident("discord-nickname", newNickname);
updateUserNickname(userId, newNickname);
}
}

Chat Application Integration​

public class ChatAppMonitor {

// Monitor group chat messages
public void onGroupMessage(String groupId, String senderId, String message) {
ParentalAI.sendTextIncident("chat-group", message);
deliverGroupMessage(groupId, senderId, message);
}

// Monitor private conversations
public void onPrivateMessage(String conversationId, String message) {
ParentalAI.sendTextIncident("chat-private", message);
deliverPrivateMessage(conversationId, message);
}

// Monitor image sharing
public void onImageShared(String conversationId, Uri imageUri) {
new Thread(() -> {
try {
Bitmap image = ImageUtils.loadBitmapFromUri(getApplicationContext(), imageUri);
String base64Image = ImageEncoder.encodeImageToBase64(image);
ParentalAI.sendImageIncident("chat-image", base64Image);

// Continue with normal sharing
runOnUiThread(() -> shareImageInChat(conversationId, imageUri));

} catch (Exception e) {
Log.e("ChatMonitor", "Failed to monitor shared image", e);
}
}).start();
}

// Monitor status updates
public void onStatusUpdated(String userId, String statusMessage) {
if (statusMessage != null && !statusMessage.trim().isEmpty()) {
ParentalAI.sendTextIncident("chat-status", statusMessage);
}
updateUserStatus(userId, statusMessage);
}
}

Educational Platform Integration​

Learning App Integration​

public class LearningAppMonitor {

// Monitor student forum posts
public void onForumPost(String forumId, String title, String content) {
ParentalAI.sendTextIncident("learning-forum-title", title);
if (content != null && !content.trim().isEmpty()) {
ParentalAI.sendTextIncident("learning-forum-post", content);
}
publishForumPost(forumId, title, content);
}

// Monitor assignment submissions (text-based)
public void onAssignmentSubmitted(String assignmentId, String submissionText) {
// Monitor for inappropriate content in submissions
ParentalAI.sendTextIncident("learning-submission", submissionText);
submitAssignment(assignmentId, submissionText);
}

// Monitor peer-to-peer messaging
public void onStudentMessage(String recipientId, String message) {
ParentalAI.sendTextIncident("learning-message", message);
sendStudentMessage(recipientId, message);
}

// Monitor project sharing descriptions
public void onProjectShared(String projectTitle, String description, Bitmap screenshot) {
ParentalAI.sendTextIncident("learning-project-title", projectTitle);

if (description != null) {
ParentalAI.sendTextIncident("learning-project-desc", description);
}

if (screenshot != null) {
try {
String base64Image = ImageEncoder.encodeImageToBase64(screenshot);
ParentalAI.sendImageIncident("learning-project", base64Image);
} catch (Exception e) {
Log.e("LearningMonitor", "Failed to monitor project screenshot", e);
}
}

shareProject(projectTitle, description, screenshot);
}
}

Creative Tools Integration​

public class CreativeToolsMonitor {

// Monitor drawing/art creation
public void onArtworkCreated(String artTitle, Bitmap artwork) {
if (artTitle != null && !artTitle.trim().isEmpty()) {
ParentalAI.sendTextIncident("creative-art-title", artTitle);
}

try {
String base64Image = ImageEncoder.encodeImageToBase64(artwork);
ParentalAI.sendImageIncident("creative-artwork", base64Image);
} catch (Exception e) {
Log.e("CreativeMonitor", "Failed to monitor artwork", e);
}

saveArtwork(artTitle, artwork);
}

// Monitor story/writing creation
public void onStoryWritten(String storyTitle, String storyContent) {
ParentalAI.sendTextIncident("creative-story-title", storyTitle);

if (storyContent != null && storyContent.length() > 10) {
ParentalAI.sendTextIncident("creative-story", storyContent);
}

saveStory(storyTitle, storyContent);
}

// Monitor music creation (if lyrics involved)
public void onSongCreated(String songTitle, String lyrics) {
ParentalAI.sendTextIncident("creative-song-title", songTitle);

if (lyrics != null && !lyrics.trim().isEmpty()) {
ParentalAI.sendTextIncident("creative-lyrics", lyrics);
}

saveSong(songTitle, lyrics);
}
}

Cross-Platform Monitoring Strategies​

Universal Content Monitor​

public class UniversalContentMonitor {
private final Map<String, String> platformMappings;

public UniversalContentMonitor() {
platformMappings = new HashMap<>();
platformMappings.put("com.roblox.client", "roblox");
platformMappings.put("com.instagram.android", "instagram");
platformMappings.put("com.zhiliaoapp.musically", "tiktok");
platformMappings.put("com.discord", "discord");
}

public void monitorContent(String packageName, String contentType, String content) {
String platform = platformMappings.getOrDefault(packageName, "unknown-app");
String platformSpecific = platform + "-" + contentType;

ParentalAI.sendTextIncident(platformSpecific, content);
}

public void monitorImage(String packageName, String contentType, Bitmap image) {
String platform = platformMappings.getOrDefault(packageName, "unknown-app");
String platformSpecific = platform + "-" + contentType;

try {
String base64Image = ImageEncoder.encodeImageToBase64(image);
ParentalAI.sendImageIncident(platformSpecific, base64Image);
} catch (Exception e) {
Log.e("UniversalMonitor", "Failed to monitor image", e);
}
}
}

Platform Detection Helper​

public class PlatformDetector {

public static String detectPlatform(Context context) {
String packageName = context.getPackageName();

// Map package names to platform identifiers
if (packageName.contains("roblox")) {
return "roblox";
} else if (packageName.contains("instagram")) {
return "instagram";
} else if (packageName.contains("tiktok") || packageName.contains("musically")) {
return "tiktok";
} else if (packageName.contains("discord")) {
return "discord";
} else if (packageName.contains("minecraft")) {
return "minecraft";
} else {
// Use a clean version of the package name
return packageName.replaceAll("[^a-zA-Z0-9]", "-").toLowerCase();
}
}

public static boolean isGamingPlatform(String platform) {
return platform.equals("roblox") ||
platform.equals("minecraft") ||
platform.contains("game");
}

public static boolean isSocialPlatform(String platform) {
return platform.equals("instagram") ||
platform.equals("tiktok") ||
platform.equals("snapchat");
}

public static boolean isMessagingPlatform(String platform) {
return platform.equals("discord") ||
platform.equals("whatsapp") ||
platform.contains("chat");
}
}

Integration Testing​

Platform-Specific Test Cases​

@RunWith(AndroidJUnit4.class)
public class PlatformIntegrationTest {

@Test
public void testRobloxChatMonitoring() {
RobloxGameMonitor monitor = new RobloxGameMonitor();

// Test normal chat
monitor.onPlayerChatMessage("player123", "Hello everyone!");

// Test potentially problematic content
monitor.onPlayerChatMessage("player456", "Want to meet up?");

// Verify monitoring calls were made
// (In real tests, you'd mock ParentalAI.sendTextIncident)
}

@Test
public void testInstagramContentMonitoring() {
InstagramStyleMonitor monitor = new InstagramStyleMonitor();

// Test post creation
List<String> hashtags = Arrays.asList("#fun", "#friends");
Bitmap testImage = createTestBitmap();

monitor.onPostCreated("Having a great day!", hashtags, testImage);

// Test profile update
monitor.onProfileUpdated("New bio here", "NewUsername", testImage);

testImage.recycle();
}

private Bitmap createTestBitmap() {
Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
bitmap.eraseColor(Color.BLUE);
return bitmap;
}
}

Performance Considerations​

Efficient Multi-Platform Monitoring​

public class EfficientPlatformMonitor {
private final ExecutorService executorService;
private final Map<String, Long> lastMonitorTime;
private static final long MINIMUM_INTERVAL = 1000; // 1 second

public EfficientPlatformMonitor() {
executorService = Executors.newFixedThreadPool(3);
lastMonitorTime = new ConcurrentHashMap<>();
}

public void monitorWithThrottling(String platform, String content) {
String key = platform + ":" + content.hashCode();
long currentTime = System.currentTimeMillis();

Long lastTime = lastMonitorTime.get(key);
if (lastTime != null && (currentTime - lastTime) < MINIMUM_INTERVAL) {
// Skip monitoring to avoid spam
return;
}

lastMonitorTime.put(key, currentTime);

executorService.submit(() -> {
try {
ParentalAI.sendTextIncident(platform, content);
} catch (Exception e) {
Log.e("EfficientMonitor", "Monitoring failed", e);
}
});
}
}

Best Practices Summary​

  1. Use platform-specific identifiers - Help parents understand where content came from
  2. Monitor key interaction points - Focus on user-generated content and communication
  3. Handle platform APIs gracefully - Don't break app functionality if monitoring fails
  4. Optimize for performance - Use background processing and throttling
  5. Respect platform guidelines - Follow each platform's terms of service
  6. Test thoroughly - Ensure monitoring works across different content types
  7. Document platform mapping - Help support teams understand incident sources

Next Steps​


Ready to implement platform-specific monitoring? Continue to Error Handling for robust error management strategies.