Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 28, 2025. It is now read-only.

License

NotificationsYou must be signed in to change notification settings

googlesamples/subgraph_sdk_sample

Repository files navigation

Introduction

This is the initial Subgraph SDK Sample that will receive an Intent from aNotifyUser call from the carrier interface. It is still in development.

Getting started

The Sample uses the google() repository so it can load the current version ofthe maven artifact, referenced in the app's build.gradle file.

The small kotlin sample on how to reference and use the api is inside:

java/com/google/samples/quickstart/subgraph_sdk_sample/MainActivity.kt (Kotlin)

Java usage will be very similar.

The carrier will send a NotifyUser RPC, which will direct the message to the SDKthat will then launch the destination_package indicated by the RPC call.

The SDK will allow getting the current CPID for the carrier.

This package should be this following target, or any other valid targetconfigured for your carrier:

com.google.samples.quickstart.subgraph_sdk_sample

  1. This activity will have a data payload that was sent by the NotifyUser RPC.Details on how to send the RPC will be provided at a later time. Be sure theactivity launch mode allows for a completely new intent to be delivered toonCreate() and onNewIntent(). Once the new intent arrives, the following

    var parsedIntent = Subgraph.fromIntent(intent)

    is a helper function that will parse out the contents for use in the app.

  2. Obtain an instance of the MobileDataPlanClient from Subgraph.See the example inMainActivity.kt.

    It should be created in a background thread, but can be also be storedoutside that scope.

    launch {  var mobileDataPlanClient =    Subgraph.newMobileDataPlanClient(applicationContext, parsedIntent.simId())}

    With this client, the app can get the current Carrier Plan ID. Run it in abackground thread, as it is a blocking call. See sample with a more completeexample.

    launch {  var dataPlanIdentifier = mobileDataPlanClient?.cpid}

    dataPlanIdentifier contains the current cpid() and the simId() correspondingto that cpid. updateTime() for that CPID is also available.

    Both Kotlin and Java can also use Guava's ListenableFuture with FluentFutureor onSuccess callbacks for more thread execution control options.

  3. Also add cleanup to the activity lifecycle, such as at onDestroy()

    mobileDataPlanClient?.close()
  4. The notification importance level is set to "HIGH_IMPORTANCE". Ask the userfor permission:https://developer.android.com/training/permissions/requesting#request-permission

    If the permission for POST_NOTIFICATIONS is already disabled, display a UIexplaining why the feature is useful, then ask the user to enable it if thefeature is useful to them. The notifications UI for the system, is locatedhere:

    Settings --> Notifications --> All Apps --> (your application name) -->All (your application name) notifications.

    Set them all to enabled.

  5. Call "resumeNotifications()" to receive notifications. Also be sure to enablenotifications in settings. By default, no notifications will be displayed.

    It is possible to resume and stop notifications. This can be tied to theapplication or service lifecycles.

    The following return a Future, but should be run in a background threadwait for completion if that is important for the app design.

    // onResume(), logIn(), etc.mobileDataPlanClient?.resumeNotifications();// onPause(), logOut(), etc.mobileDataPlanClient?.stopNotifications();

This project uses the Gradle build system. To build this project, use thegradlew build command or use "Import Project" in Android Studio.

For more resources on learning Android development, visit theDeveloper Guides atdeveloper.android.com.

Required setup

The subgraph_sdk_sample will have this setup already. Subgraph SDK will be inthe google() repository:

repositories {  google()  // ...}

In your app directory's build.gradle, add to the dependencies this line:

dependencies {  implementation 'com.google.android.libraries.cloud.telco.subgraph:cloud_telco_subgraph:0.5.3'}

The android gradle plugin may need to be updated to at least version 7.3.1 whenthe sample is first loaded. Upgrade when prompted by Android Studio.

If the app does not already have an OSS plugin to help with Third PartyLicenses generation and display, please go here:

https://developers.google.com/android/guides/opensource

Support

Please report issues with this sample in this project's issues page:https://github.com/googlesamples/subgraph-sdk-sample/issues

License

Copyright 2022 Google, Inc.Licensed to the Apache Software Foundation (ASF) under one or more contributorlicense agreements.  See the NOTICE file distributed with this work foradditional information regarding copyright ownership.  The ASF licenses thisfile to you under the Apache License, Version 2.0 (the "License"); you may notuse this file except in compliance with the License.  You may obtain a copy ofthe License at  http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS, WITHOUTWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See theLicense for the specific language governing permissions and limitations underthe License.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp