本文整理汇总了Java中com.onesignal.OneSignal类的典型用法代码示例。如果您正苦于以下问题:Java OneSignal类的具体用法?Java OneSignal怎么用?Java OneSignal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OneSignal类属于com.onesignal包,在下文中一共展示了OneSignal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendOneSignalTags
import com.onesignal.OneSignal; //导入依赖的package包/类
public void sendOneSignalTags() {
try {
JSONObject tags = new JSONObject();
tags.put("ImportantInformation", PreferenceManager.getDefaultSharedPreferences(applicationContext).getBoolean("important_switch", true));
tags.put("UnavailableStations", PreferenceManager.getDefaultSharedPreferences(applicationContext).getBoolean("unavailable_switch", true));
tags.put("AvailableStations", PreferenceManager.getDefaultSharedPreferences(applicationContext).getBoolean("available_switch", true));
tags.put("NewStations", PreferenceManager.getDefaultSharedPreferences(applicationContext).getBoolean("new_stations_switch", true));
tags.put("AirQualityAlerts", PreferenceManager.getDefaultSharedPreferences(applicationContext).getBoolean("air_quality_switch", true));
tags.put("rate", Preferences.getInstance(applicationContext).isRateDone());
Gson gson = new Gson();
FavoriteItem[] favorites = gson.fromJson(Preferences.getInstance(applicationContext).getIdFav(), FavoriteItem[].class);
if (favorites != null && favorites.length > 0) {
for (int i = 0; i < favorites.length; i++) {
String favText = String.format("Station%s", favorites[i].getId());
tags.put(favText, true);
}
}
OneSignal.sendTags(tags);
} catch (JSONException e) {
//e.printStackTrace();
}
}
示例2: onResume
import com.onesignal.OneSignal; //导入依赖的package包/类
@Override
protected void onResume() {
super.onResume();
userStatusRef.setValue(UserStatus.ONLINE.ordinal());
// Clear all notification
OneSignal.clearOneSignalNotifications();
// Check contacts
if (AppManager.getInstance().phoneContacts.isEmpty() && !AppManager.getInstance().loadedPhoneContacts) {
// analysis
Bundle params = new Bundle();
params.putString("user", mUser.getPhone());
References.getInstance().analytics.logEvent("empty_contacts", params);
startActivity(new Intent(this, AppSplashActivity.class));
this.finish();
AppManager.getInstance().loadedPhoneContacts = true;
}
}
示例3: onCreate
import com.onesignal.OneSignal; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
OneSignal.init(this, "", "", new NotificationOpenedHandler() {
@Override
public void notificationOpened(String s, JSONObject jsonObject, boolean b) {
}
});
tvAddress = (TextView) findViewById(R.id.tvAddress);
tvDateTime = (TextView) findViewById(R.id.tvDateTime);
tvTitle = (TextView) findViewById(R.id.tvTitle);
tvDetails = (TextView) findViewById(R.id.tvDetails);
mainProgressBar = (ProgressBar) findViewById(R.id.mainProgressBar);
mainView = (LinearLayout) findViewById(R.id.mainView);
failedView = (LinearLayout) findViewById(R.id.failedView);
LoadData();
}
示例4: onCreate
import com.onesignal.OneSignal; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
// http://stackoverflow.com/a/9752494
try {
Class.forName("android.os.AsyncTask");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
OneSignal.startInit(this).init();
OneSignal.idsAvailable(new OneSignal.IdsAvailableHandler() {
@Override
public void idsAvailable(String userId, String registrationId) {
setOneSignalPlayerId(userId);
}
});
}
示例5: registerOneSignal
import com.onesignal.OneSignal; //导入依赖的package包/类
private void registerOneSignal(final String deviceName) {
OneSignal
.startInit(ApplicationController.getInstance().getApplicationContext())
.inFocusDisplaying(OneSignal.OSInFocusDisplayOption.None)
.init();
OneSignal.idsAvailable(new OneSignal.IdsAvailableHandler() {
@Override
public void idsAvailable(String userId, String registrationId) {
String deviceToken = userId;
spEditor.putString("one_signal_device_token", userId);
spEditor.commit();
// Log it for debugging purposes
Log.d("RegisterNotifications", "OneSignal device token: " + deviceToken + " - Device Name: " + deviceName);
if (shouldRegister(deviceToken)) {
registerWithServer(deviceToken, deviceName);
}
}
});
}
示例6: setAllSwitch
import com.onesignal.OneSignal; //导入依赖的package包/类
public void setAllSwitch(boolean key) {
this.sharedPrefs = this.appContext.getSharedPreferences(PREFS_NAME, 0);
this.prefsEditor = this.sharedPrefs.edit();
this.prefsEditor.putBoolean(PREFS_SWITCH_ALL, key);
this.prefsEditor.apply();
if (key) {
resetSwitches();
} else {
JSONObject tags = new JSONObject();
try {
tags.put("ALL-Filter", false);
} catch (JSONException e) {
e.printStackTrace();
}
OneSignal.sendTags(tags);
}
}
示例7: onCreate
import com.onesignal.OneSignal; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
sInstance = this;
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
OneSignal.startInit(this).setNotificationOpenedHandler(new MADBikeNotificationOpenedHandler(this)).init();
Branch.getAutoInstance(this);
Dexter.initialize(this);
}
示例8: onCreate
import com.onesignal.OneSignal; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
OneSignal.startInit(this)
.inFocusDisplaying(OneSignal.OSInFocusDisplayOption.InAppAlert)
.setNotificationReceivedHandler(new ExampleNotificationReceivedHandler())
.setNotificationOpenedHandler(new ExampleNotificationOpenedHandler()).init();
myApplication=this;
}
示例9: onCreate
import com.onesignal.OneSignal; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
OneSignal.startInit(this)
.inFocusDisplaying(OneSignal.OSInFocusDisplayOption.InAppAlert)
.setNotificationReceivedHandler(new ExampleNotificationReceivedHandler())
.setNotificationOpenedHandler(new ExampleNotificationOpenedHandler()).init();
myApplication=this;
}
示例10: setSwitchVan
import com.onesignal.OneSignal; //导入依赖的package包/类
public void setSwitchVan(boolean key) {
this.sharedPrefs = this.appContext.getSharedPreferences(PREFS_NAME, 0);
this.prefsEditor = this.sharedPrefs.edit();
this.prefsEditor.putBoolean(PREFS_SWITCH_VAN, key);
this.prefsEditor.apply();
JSONObject tags = new JSONObject();
try {
tags.put("Van", key);
} catch (JSONException e) {
e.printStackTrace();
}
OneSignal.sendTags(tags);
}
示例11: setSwitchKSC
import com.onesignal.OneSignal; //导入依赖的package包/类
public void setSwitchKSC(boolean key) {
this.sharedPrefs = this.appContext.getSharedPreferences(PREFS_NAME, 0);
this.prefsEditor = this.sharedPrefs.edit();
this.prefsEditor.putBoolean(PREFS_SWITCH_KSC, key);
this.prefsEditor.apply();
JSONObject tags = new JSONObject();
try {
tags.put("KSC", key);
} catch (JSONException e) {
e.printStackTrace();
}
OneSignal.sendTags(tags);
}
示例12: setSwitchPles
import com.onesignal.OneSignal; //导入依赖的package包/类
public void setSwitchPles(boolean key) {
this.sharedPrefs = this.appContext.getSharedPreferences(PREFS_NAME, 0);
this.prefsEditor = this.sharedPrefs.edit();
this.prefsEditor.putBoolean(PREFS_SWITCH_PLES, key);
this.prefsEditor.apply();
JSONObject tags = new JSONObject();
try {
tags.put("Ples", key);
} catch (JSONException e) {
e.printStackTrace();
}
OneSignal.sendTags(tags);
}
示例13: setSwitchCape
import com.onesignal.OneSignal; //导入依赖的package包/类
public void setSwitchCape(boolean key) {
this.sharedPrefs = this.appContext.getSharedPreferences(PREFS_NAME, 0);
this.prefsEditor = this.sharedPrefs.edit();
this.prefsEditor.putBoolean(PREFS_SWITCH_CAPE, key);
this.prefsEditor.apply();
JSONObject tags = new JSONObject();
try {
tags.put("Cape", key);
} catch (JSONException e) {
e.printStackTrace();
}
OneSignal.sendTags(tags);
}
示例14: setSwitchNasa
import com.onesignal.OneSignal; //导入依赖的package包/类
public void setSwitchNasa(boolean key) {
this.sharedPrefs = this.appContext.getSharedPreferences(PREFS_NAME, 0);
this.prefsEditor = this.sharedPrefs.edit();
this.prefsEditor.putBoolean(PREFS_SWITCH_NASA, key);
this.prefsEditor.apply();
JSONObject tags = new JSONObject();
try {
tags.put("Nasa", key);
} catch (JSONException e) {
e.printStackTrace();
}
OneSignal.sendTags(tags);
}
示例15: setSwitchSpaceX
import com.onesignal.OneSignal; //导入依赖的package包/类
public void setSwitchSpaceX(boolean key) {
this.sharedPrefs = this.appContext.getSharedPreferences(PREFS_NAME, 0);
this.prefsEditor = this.sharedPrefs.edit();
this.prefsEditor.putBoolean(PREFS_SWITCH_SPACEX, key);
this.prefsEditor.apply();
JSONObject tags = new JSONObject();
try {
tags.put("SpaceX", key);
} catch (JSONException e) {
e.printStackTrace();
}
OneSignal.sendTags(tags);
}